specimen-room-view.component.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  1. import { Component, OnInit, ViewChild, OnDestroy } from "@angular/core";
  2. import { MainService } from "../../services/main.service";
  3. import { Router } from "@angular/router";
  4. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  5. import { startOfDay, format, endOfDay } from "date-fns";
  6. import { ToolService } from 'src/app/services/tool.service';
  7. import { NzMessageService } from "ng-zorro-antd";
  8. import { debounceTime } from 'rxjs/operators';
  9. import { Subject } from 'rxjs';
  10. import {
  11. FormBuilder,
  12. Validators,
  13. FormGroup,
  14. FormControl,
  15. } from "@angular/forms";
  16. @Component({
  17. selector: "app-specimen-room-view",
  18. templateUrl: "./specimen-room-view.component.html",
  19. styleUrls: ["./specimen-room-view.component.less"],
  20. })
  21. export class SpecimenRoomViewComponent implements OnInit, OnDestroy {
  22. @ViewChild("osComponentRef1", {
  23. read: OverlayScrollbarsComponent,
  24. static: false,
  25. })
  26. osComponentRef1: OverlayScrollbarsComponent;
  27. @ViewChild("osComponentRef2", {
  28. read: OverlayScrollbarsComponent,
  29. static: false,
  30. })
  31. osComponentRef2: OverlayScrollbarsComponent;
  32. @ViewChild("osComponentRef3", {
  33. read: OverlayScrollbarsComponent,
  34. static: false,
  35. })
  36. osComponentRef3: OverlayScrollbarsComponent;
  37. @ViewChild("osComponentRef4", {
  38. read: OverlayScrollbarsComponent,
  39. static: false,
  40. })
  41. osComponentRef4: OverlayScrollbarsComponent;
  42. @ViewChild("osComponentRef5", {
  43. read: OverlayScrollbarsComponent,
  44. static: false,
  45. })
  46. osComponentRef5: OverlayScrollbarsComponent;
  47. constructor(
  48. private mainService: MainService,
  49. public router: Router,
  50. public tool: ToolService,
  51. private fb: FormBuilder,
  52. private message: NzMessageService,
  53. ) {}
  54. // 今日药单量
  55. todayTotal: undefined;
  56. // 今日已完成
  57. todayComplete: undefined;
  58. //手术间数据
  59. printPharmacyList = []; //数据列表
  60. printPharmacyIdx = 0; //页码
  61. printPharmacyTotal = 0; //总数
  62. printPharmacyFlag = false; //是否查看更多
  63. printPharmacySearchKey = ""; //搜索的内容
  64. printPharmacyLoad = false; //按钮的loading
  65. // 标本间列表
  66. waitPharmacyList = [];
  67. waitPharmacyIdx = 0;
  68. waitPharmacyTotal = 0;
  69. waitPharmacyFlag = false;
  70. waitPharmacySearchKey = "";
  71. waitPharmacyLoad = false;
  72. // 今日离科列表
  73. pharmacyList = [];
  74. pharmacyIdx = 0;
  75. pharmacyTotal = 0;
  76. pharmacyFlag = false;
  77. pharmacySearchKey = "";
  78. pharmacyLoad = false;
  79. // 配送中列表
  80. distributionList = [];
  81. distributionIdx = 0;
  82. distributionTotal = 0;
  83. distributionFlag = false;
  84. distributionSearchKey = "";
  85. distributionLoad = false;
  86. // 已完成列表
  87. completedList = [];
  88. completedIdx = 0;
  89. completedTotal = 0;
  90. completedFlag = false;
  91. completedSearchKey = "";
  92. completedLoad = false;
  93. barCode:any; //条码搜索
  94. // other
  95. loginUser: any = localStorage.getItem("user")
  96. ? JSON.parse(localStorage.getItem("user")).user
  97. : null; //登录人信息
  98. logTimer = null; //定时器
  99. logTime = 0; //自动刷新秒数
  100. logTimeConst = 60; //自动刷新秒数
  101. time = new Date().getTime(); // 时间戳
  102. timer = null; // 时间定时器
  103. relevanceModal:boolean = false //关联标本和手术室
  104. validateForm: FormGroup; //关联标本和手术室表单
  105. validateVerificationForm: FormGroup; //核验标本
  106. specimenData:any = []; //标本间数据
  107. operationData:any = []; //手术间数据
  108. fixationModal:boolean = false //标本接收固定
  109. verificationMoadl:boolean = false //标本核验
  110. specimenCode:any; //标本条码
  111. listOfData:any=[];
  112. fixativeData:any = []; //固体液类型
  113. hosId:any;
  114. userId:any;
  115. detailsData:any;
  116. isSpinning:boolean = false; //全屏加载状态
  117. codeData:any; //标本条码数据
  118. btnInfoLoading :boolean = false; //标本加固加载
  119. searchMsg:any = null;
  120. changeInpSubject = new Subject(); //防抖
  121. changeInpSubjectSpecimen = new Subject(); //防抖
  122. ngOnDestroy() {
  123. clearTimeout(this.timer);
  124. clearTimeout(this.logTimer);
  125. }
  126. ngOnInit() {
  127. this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
  128. this.searchSpecimenData(v[0])
  129. });
  130. this.changeInpSubjectSpecimen.pipe(debounceTime(500)).subscribe((v) => {
  131. this.searchSpecimen(v[0])
  132. });
  133. this.hosId = this.tool.getCurrentHospital().id;
  134. this.userId = this.tool.getCurrentUserId()
  135. this.runTime();
  136. // 统计
  137. // this.total();
  138. this.getDept()
  139. // 切换科室
  140. // this.changeKs();
  141. this.initRole();
  142. // 自动刷新倒计时 start
  143. this.autoUpdate();
  144. // 自动刷新倒计时 end
  145. setTimeout(_=>{
  146. document.getElementById('Binput').focus();
  147. },200)
  148. }
  149. // 当前时间日期
  150. runTime() {
  151. clearTimeout(this.timer);
  152. this.timer = setTimeout(() => {
  153. this.time = Date.now();
  154. this.runTime();
  155. }, 500);
  156. }
  157. // 标本条码搜索
  158. searchSpecimen(e){
  159. if(!this.barCode){
  160. return
  161. }
  162. if(this.barCode.length < 10) {
  163. return
  164. }
  165. let data={
  166. barcode:e
  167. }
  168. this.isSpinning = true
  169. clearInterval(this.logTimer);
  170. this.mainService.pathologyScanCode(data)
  171. .subscribe((res:any) => {
  172. this.isSpinning = false
  173. if(res.status==200){
  174. this.codeData = res.data[0]
  175. let item = this.codeData.pathologySpecimenDTOList.find(i=>i.specimenCode == e)
  176. console.log(7,item)
  177. if(!item.fixationTime && this.codeData.pathologyFormType==0){
  178. if(this.codeData.status.value==2 || this.codeData.status.value==3 ||
  179. this.codeData.status.value==4){
  180. if(this.codeData.pathologyInspectDTOS){
  181. this.project = this.codeData.pathologyInspectDTOS.map(i=>{
  182. return i.inspectProject.name
  183. })
  184. this.project = this.project.join('、')
  185. }
  186. this.getFixationNum(this.codeData.id)
  187. }else{
  188. this.viewDetail(this.codeData,'4')
  189. }
  190. this.fixationError = null
  191. this.searchMsg = null
  192. }else if(item.fixationTime && this.codeData.pathologyFormType==0){
  193. this.viewDetail(this.codeData,'4')
  194. this.barCode = null
  195. this.fixationError = null
  196. this.searchMsg = null
  197. }else{
  198. this.barCode = null
  199. this.fixationError = null
  200. this.searchMsg = '该申请单类型不是病理检查申请单'
  201. }
  202. }else{
  203. this.barCode = null
  204. this.searchMsg = res.msg
  205. }
  206. })
  207. }
  208. // 获取申请单扫标本信息
  209. fixationNum:any;
  210. specimenNum:any;
  211. totalNum:any
  212. getFixationNum(id){
  213. this.mainService.pathologyCheckPrint('pathologyForm',id,{
  214. operationType:'fixation'
  215. }).subscribe((res:any)=>{
  216. this.fixationModal = true
  217. this.fixationNum = res.fixationNum
  218. this.specimenNum = res.specimenNum
  219. this.totalNum = res.totalNum
  220. setTimeout(_=>{
  221. document.getElementById('specimen').focus();
  222. },200)
  223. })
  224. }
  225. // 选择固定时间
  226. formChangeDate(result){
  227. this.startDate = format(result, 'yyyy-MM-dd HH:mm:ss');
  228. }
  229. // 确定接受固定标本
  230. startDate:any;
  231. submitFixationForm(){
  232. this.validateVerificationForm = this.fb.group({
  233. fixationTime: [null, [Validators.required]],
  234. jobNumber: [null, [Validators.required]],
  235. name:[null, [Validators.required]],
  236. fixative:[null, [Validators.required]],
  237. });
  238. let date = new Date();
  239. this.startDate = format(date, "yyyy-MM-dd HH:mm:ss")
  240. this.validateVerificationForm.controls.fixationTime.setValue(this.startDate);
  241. this.btnLoading = true
  242. this.mainService.getDictionary("list", "fixing_liquid_type").subscribe((res) => {
  243. this.fixativeData = res
  244. this.btnLoading = false
  245. this.verificationMoadl = true
  246. });
  247. }
  248. // 关闭接受固定标本
  249. hideSpecimenModal(){
  250. this.autoUpdate()
  251. this.cancelSpecimenModal()
  252. this.barCode = null;
  253. this.specimenCode = null;
  254. this.fixationError = null
  255. this.fixationModal = false;
  256. setTimeout(_=>{
  257. document.getElementById('Binput').focus();
  258. },200)
  259. }
  260. cancelSpecimenModal(){
  261. let ids = []
  262. for(let i of this.codeData.pathologySpecimenDTOList){
  263. ids.push(i.id)
  264. }
  265. let data = {
  266. pathologySpecimenIds:ids.join(',')
  267. }
  268. this.mainService.pathologyOperation(data,'cancel').subscribe((res) =>{
  269. })
  270. }
  271. // 获取标本详情
  272. project:any = [];
  273. getSampleData(item){
  274. this.mainService.getFetchData("data", "pathologyForm", item.id)
  275. .subscribe((data) => {
  276. this.isSpinning = false
  277. this.detailsData = data.data
  278. this.specimenList = data.data.pathologySpecimenDTOList||[]
  279. this.pathologyLogs = data.data.formLogDTOS
  280. this.stepLength = this.pathologyLogs.length
  281. if(this.detailsData.pathologyInspectDTOS){
  282. this.project = this.detailsData.pathologyInspectDTOS.map(i=>{
  283. return i.inspectProject.name
  284. })
  285. this.project = this.project.join('、')
  286. }
  287. this.detailMoadl = true
  288. });
  289. }
  290. // 关闭查看标本
  291. closeSpecimenModal(){
  292. this.specimenViewDialog = false
  293. }
  294. // 查看标本
  295. specimenViewDialog:any = false;
  296. viewData:any = [];
  297. specimenItem:any;
  298. specimenView(item){
  299. this.viewData = []
  300. this.specimenViewDialog = true
  301. this.specimenItem = item;
  302. this.viewData.push(item)
  303. }
  304. // 获取科室
  305. getDept(){
  306. this.setSpecimen()
  307. var that = this;
  308. that.mainService.getDictionary("list", "dept_type").subscribe((res2) => {
  309. let item1 = res2.find(i=>i.name=='手术室科室')
  310. let item2 = res2.find(i=>i.name=='标本间科室')
  311. let data1 = {
  312. idx: 0,
  313. sum: 9999,
  314. department: {
  315. hospital: { id: that.hosId || "" },
  316. type: { id: item1.id || "" },
  317. },
  318. };
  319. let data2 = {
  320. idx: 0,
  321. sum: 9999,
  322. department: {
  323. hospital: { id: that.hosId || "" },
  324. type: { id: item2.id || "" },
  325. },
  326. };
  327. that.mainService
  328. .getFetchDataList("data", "department", data1)
  329. .subscribe((res) => {
  330. that.operationData = res.list;
  331. });
  332. that.mainService
  333. .getFetchDataList("data", "department", data2)
  334. .subscribe((res) => {
  335. that.specimenData = res.list
  336. this.getDeptDetail()
  337. });
  338. });
  339. }
  340. // 获取关联科室详情
  341. getDeptDetail(){
  342. this.mainService
  343. .transfusionPrint("user", this.userId)
  344. .subscribe((res) => {
  345. let data = res.data;
  346. if(data.surgeryDepts){
  347. let deptArr = []
  348. for(let i of data.surgeryDepts){
  349. deptArr.push(i.id)
  350. }
  351. this.validateForm.controls.operation.setValue(deptArr);
  352. }
  353. this.validateForm.controls.specimen.setValue(data.dept.id);
  354. if(data.autoCreateOrder){
  355. this.validateForm.controls.generate.setValue(data.autoCreateOrder);
  356. }
  357. });
  358. }
  359. // 获取是否关联标本间
  360. setSpecimen(){
  361. if(this.validateForm){
  362. this.validateForm = this.fb.group({
  363. specimen: [this.validateForm.value.specimen, [Validators.required]],
  364. operation: [this.validateForm.value.operation, [Validators.required]],
  365. generate:[this.validateForm.value.generate, [Validators.required]],
  366. });
  367. }else{
  368. this.validateForm = this.fb.group({
  369. specimen: [null, [Validators.required]],
  370. operation: [null, [Validators.required]],
  371. generate:[1, [Validators.required]],
  372. });
  373. }
  374. this.relevanceModal = true
  375. }
  376. // 确定关联科室
  377. btnLoading:boolean = false;
  378. submitForm(){
  379. for (const i in this.validateForm.controls) {
  380. this.validateForm.controls[i].markAsDirty();
  381. this.validateForm.controls[i].updateValueAndValidity();
  382. }
  383. if (this.validateForm.invalid) return;
  384. let deptArr = this.validateForm.value.operation.join(',')
  385. let data = {
  386. user: {
  387. autoCreateOrder: this.validateForm.value.generate,
  388. dept:{
  389. id:this.validateForm.value.specimen
  390. },
  391. surgeryDeptIds:deptArr,
  392. id:this.userId
  393. },
  394. };
  395. this.btnLoading = true
  396. this.mainService
  397. .coopData("updData", "user", data)
  398. .subscribe((data) => {
  399. this.getNewDept()
  400. // 手术间列表
  401. this.getPharmacyList(this.printPharmacyIdx, 'surgeryDept', this.printPharmacySearchKey);
  402. // 标本间列表
  403. this.getPharmacyList(this.waitPharmacyIdx, 'specimenDept', this.waitPharmacySearchKey);
  404. // 今日离科标本列表
  405. this.getPharmacyList(this.pharmacyIdx, 'leavedDept', this.pharmacySearchKey);
  406. this.btnLoading = false
  407. this.relevanceModal = false
  408. if (data.status == 200) {
  409. this.showPromptModal("操作", true, "");
  410. } else {
  411. this.showPromptModal("操作", false, data.msg);
  412. }
  413. });
  414. }
  415. getNewDept(){
  416. let postData = {
  417. currentHosId: this.hosId,
  418. loginType: "PC",
  419. };
  420. this.mainService.changeHospital(postData).subscribe((result) => {
  421. if (result.status == 200) {
  422. let dataObj = {
  423. user: {
  424. dept: {
  425. id: this.validateForm.value.specimen,
  426. },
  427. id: JSON.parse(localStorage.getItem("user")).user.id,
  428. },
  429. };
  430. this.mainService
  431. .coopData("updData", "user", dataObj)
  432. .subscribe((data) => {
  433. if (data.status == 200) {
  434. this.getCurrentUserNow();
  435. }
  436. });
  437. }
  438. });
  439. }
  440. // 获取当前用户信息
  441. getCurrentUserNow() {
  442. this.mainService.getCurrentUser1().subscribe((data:any) => {
  443. if (data["status"] == 200) {
  444. this.loginUser = data.data
  445. let user = JSON.parse(localStorage.getItem("user"));
  446. user.user.dept = data["data"].dept;
  447. user.user.currentHospital = data["data"].currentHospital;
  448. localStorage.setItem("user", JSON.stringify(user));
  449. }
  450. });
  451. }
  452. // 输入工号查询姓名
  453. handoverUserId:any = null;
  454. numberChange(e){
  455. if(e.length < 3) {
  456. this.validateVerificationForm.controls.name.setValue('');
  457. return
  458. }
  459. let query = {
  460. account: e
  461. };
  462. this.mainService
  463. .jobSearch(query)
  464. .subscribe((data:any) => {
  465. if(data.status==200){
  466. this.validateVerificationForm.controls.name.setValue(data.userName);
  467. this.handoverUserId = data.userId
  468. }else{
  469. this.validateVerificationForm.controls.name.setValue('');
  470. this.handoverUserId =null
  471. // this.message.error(data.data)
  472. }
  473. });
  474. }
  475. // 提交固定标本接收
  476. submitVerificationForm(){
  477. for (const i in this.validateVerificationForm.controls) {
  478. this.validateVerificationForm.controls[i].markAsDirty();
  479. this.validateVerificationForm.controls[i].updateValueAndValidity();
  480. }
  481. if (this.validateVerificationForm.invalid) return;
  482. let str = this.codeData.pathologySpecimenDTOList.map(i=>{
  483. return i.specimenCode
  484. })
  485. let data: any = {
  486. id:this.codeData.id,
  487. specimenDeptId:this.validateForm.value.specimen,
  488. specimenFixingLiquid:{
  489. id:this.validateVerificationForm.value.fixative
  490. },
  491. specimenCodes:str.join(','),
  492. fixationTime:this.startDate,
  493. hosId: this.hosId || "" ,
  494. handoverUserId:this.handoverUserId
  495. };
  496. this.btnInfoLoading = true;
  497. this.mainService
  498. .simplePost("addData", "pathologyForm", data)
  499. .subscribe((res) => {
  500. this.autoUpdate(false)
  501. this.btnInfoLoading = false;
  502. this.barCode = null;
  503. // 手术间列表
  504. this.getPharmacyList(this.printPharmacyIdx, 'surgeryDept', this.printPharmacySearchKey);
  505. // 标本间列表
  506. this.getPharmacyList(this.waitPharmacyIdx, 'specimenDept', this.waitPharmacySearchKey);
  507. // 今日离科标本列表
  508. this.getPharmacyList(this.pharmacyIdx, 'leavedDept', this.pharmacySearchKey);
  509. if (res.status == 200) {
  510. this.showPromptModal("操作", true, "");
  511. } else {
  512. this.showPromptModal("操作", false, res.msg);
  513. }
  514. });
  515. }
  516. closeModel(){
  517. this.verificationMoadl = false
  518. this.fixationModal = false
  519. setTimeout(_=>{
  520. document.getElementById('Binput').focus();
  521. },200)
  522. }
  523. // 关闭固定接受标本
  524. hideVerificationModal(){
  525. this.verificationMoadl = false
  526. setTimeout(_=>{
  527. document.getElementById('Binput').focus();
  528. },200)
  529. }
  530. // 监听标本条码
  531. specimenCodeChange(e){
  532. this.changeInpSubjectSpecimen.next([e]);
  533. }
  534. // 监听接受固定标本条码
  535. tableLoading:boolean = false;
  536. codeChange(e){
  537. this.changeInpSubject.next([e]);
  538. }
  539. fixationError:any;
  540. searchSpecimenData(e){
  541. if(!e){
  542. return
  543. }
  544. if(e.length < 10) {
  545. return
  546. }
  547. this.tableLoading = true
  548. this.mainService.pathologyScanCode({
  549. barcode:e,
  550. pathologyFormId:this.codeData.id
  551. })
  552. .subscribe((res:any) => {
  553. this.autoUpdate(false)
  554. this.tableLoading = false
  555. this.specimenCode = null
  556. if(res.status==200){
  557. let item = res.data[0].pathologySpecimenDTOList.find(i=>i.specimenCode == e)
  558. if(item.fixationTime){
  559. this.fixationError = '该标本已经固定过'
  560. }else{
  561. this.getFixationNum(res.data[0].id)
  562. this.codeData = res.data[0]
  563. this.fixationError = null
  564. }
  565. }else{
  566. this.fixationError = res.msg
  567. }
  568. })
  569. }
  570. // 查看详情
  571. detailMoadl:boolean = false;
  572. pathologyLogs:any=[];
  573. specimenList:any=[]
  574. stepLength:any = 0;
  575. viewDetail(item,type){
  576. this.isSpinning = true
  577. this.getSampleData(item)
  578. clearInterval(this.logTimer);
  579. }
  580. closeDetailMoadl(){
  581. setTimeout(_=>{
  582. document.getElementById('Binput').focus();
  583. },200)
  584. this.detailMoadl = false
  585. this.autoUpdate(false);
  586. }
  587. // 自动刷新倒计时
  588. autoUpdate(flag = true) {
  589. if (flag) {
  590. this.logTime = this.logTimeConst;
  591. }
  592. clearInterval(this.logTimer);
  593. this.logTimer = setInterval(() => {
  594. this.logTime--;
  595. if (this.logTime === 0) {
  596. this.logTime = this.logTimeConst;
  597. // 代收急查标本(标本信息)列表
  598. this.getPharmacyList(0, 'surgeryDept', this.printPharmacySearchKey);
  599. // 已收取(工单信息)列表
  600. this.getPharmacyList(0, 'specimenDept', this.waitPharmacySearchKey);
  601. // 中转标本(标本统计信息)列表
  602. this.getPharmacyList(0, 'leavedDept', this.pharmacySearchKey);
  603. }
  604. }, 1000);
  605. }
  606. // 药房端药房列表查询、搜索
  607. // 1为pc待打印状态、2为pc配药中、3为pc核对中、4为pc配送中
  608. // searchKey 为搜索的关键字,没有就不传
  609. loading1 = false;
  610. loading2 = false;
  611. loading3 = false;
  612. loading4 = false;
  613. loading5 = false;
  614. getPharmacyList(idx, type, searchKey) {
  615. let hosId = JSON.parse(localStorage.getItem("user")).user.currentHospital.id;
  616. switch (type) {
  617. case 'surgeryDept':
  618. this.loading1 = true;
  619. break;
  620. case 'specimenDept':
  621. this.loading2 = true;
  622. break;
  623. case 'leavedDept':
  624. this.loading3 = true;
  625. break;
  626. }
  627. let postData = {
  628. idx: 0,
  629. sum: 50,
  630. pathologyForm:{
  631. detailsType: type,
  632. keyWords:searchKey,
  633. hosId,
  634. }
  635. };
  636. this.mainService
  637. .getFetchDataList("data", "pathologyForm", postData)
  638. .subscribe((result) => {
  639. switch (type) {
  640. case 'surgeryDept':
  641. this.loading1 = false;
  642. break;
  643. case 'specimenDept':
  644. this.loading2 = false;
  645. break;
  646. case 'leavedDept':
  647. this.loading3 = false;
  648. break;
  649. }
  650. if (result["status"] == 200) {
  651. switch (type) {
  652. case 'surgeryDept':
  653. // 总数
  654. this.printPharmacyTotal = result.totalNum;
  655. // 隐藏按钮的loading
  656. this.printPharmacyLoad = false;
  657. // 查看更多,是否显示
  658. if (result["list"].length < 10) {
  659. this.printPharmacyFlag = false;
  660. } else if (result["list"].length === 0 && idx === 0) {
  661. this.printPharmacyFlag = false;
  662. } else {
  663. this.printPharmacyFlag = true;
  664. }
  665. // 列表数据合并
  666. if (idx === 0) {
  667. this.printPharmacyList = result["list"];
  668. } else {
  669. this.printPharmacyList = [
  670. ...this.printPharmacyList,
  671. ...result["list"],
  672. ];
  673. }
  674. break;
  675. case 'specimenDept':
  676. this.waitPharmacyTotal = result.totalNum;
  677. this.waitPharmacyLoad = false;
  678. if (result["list"].length < 10) {
  679. this.waitPharmacyFlag = false;
  680. } else if (result["list"].length === 0 && idx === 0) {
  681. this.waitPharmacyFlag = false;
  682. } else {
  683. this.waitPharmacyFlag = true;
  684. }
  685. if (idx === 0) {
  686. this.waitPharmacyList = result["list"];
  687. } else {
  688. this.waitPharmacyList = [
  689. ...this.waitPharmacyList,
  690. ...result["list"],
  691. ];
  692. }
  693. break;
  694. case 'leavedDept':
  695. this.pharmacyTotal = result.totalNum;
  696. this.pharmacyLoad = false;
  697. if (result["list"].length < 10) {
  698. this.pharmacyFlag = false;
  699. } else if (result["list"].length === 0 && idx === 0) {
  700. this.pharmacyFlag = false;
  701. } else {
  702. this.pharmacyFlag = true;
  703. }
  704. if (idx === 0) {
  705. this.pharmacyList = result["list"];
  706. } else {
  707. this.pharmacyList = [...this.pharmacyList, ...result["list"]];
  708. }
  709. break;
  710. }
  711. }
  712. });
  713. }
  714. // 加载更多
  715. // loadMore(type) {
  716. // switch (type) {
  717. // case 'surgeryDept':
  718. // this.printPharmacyIdx++;
  719. // this.printPharmacyLoad = true;
  720. // this.getPharmacyList(
  721. // this.printPharmacyIdx,
  722. // type,
  723. // this.printPharmacySearchKey
  724. // );
  725. // break;
  726. // case 'specimenDept':
  727. // this.waitPharmacyIdx++;
  728. // this.waitPharmacyLoad = true;
  729. // this.getPharmacyList(
  730. // this.waitPharmacyIdx,
  731. // type,
  732. // this.waitPharmacySearchKey
  733. // );
  734. // break;
  735. // case 'leavedDept':
  736. // this.pharmacyIdx++;
  737. // this.pharmacyLoad = true;
  738. // this.getPharmacyList(this.pharmacyIdx, type, this.pharmacySearchKey);
  739. // break;
  740. // }
  741. // }
  742. // 搜索关键词
  743. searchKeyHandle(type) {
  744. switch (type) {
  745. case 'surgeryDept':
  746. this.printPharmacyIdx = 0; //页码重置
  747. this.printPharmacyList = []; //列表重置
  748. this.getPharmacyList(
  749. this.printPharmacyIdx,
  750. type,
  751. this.printPharmacySearchKey
  752. );
  753. break;
  754. case 'specimenDept':
  755. this.waitPharmacyIdx = 0; //页码重置
  756. this.waitPharmacyList = []; //列表重置
  757. this.getPharmacyList(
  758. this.waitPharmacyIdx,
  759. type,
  760. this.waitPharmacySearchKey
  761. );
  762. break;
  763. case 'leavedDept':
  764. this.pharmacyIdx = 0; //页码重置
  765. this.pharmacyList = []; //列表重置
  766. this.getPharmacyList(this.pharmacyIdx, type, this.pharmacySearchKey);
  767. break;
  768. }
  769. }
  770. // 退出
  771. logOut(): void {
  772. // 假退出
  773. let hospital = this.tool.getCurrentHospital();
  774. if(hospital){
  775. this.router.navigate(["login", hospital.id]);
  776. }else{
  777. this.router.navigateByUrl("login");
  778. }
  779. localStorage.removeItem("user");
  780. localStorage.removeItem("menu");
  781. localStorage.removeItem("index");
  782. // 假退出
  783. this.mainService.logOut().subscribe((data) => {
  784. if (data.status == 200) {
  785. if(hospital){
  786. this.router.navigate(["login", hospital.id]);
  787. }else{
  788. this.router.navigateByUrl("login");
  789. }
  790. localStorage.removeItem("user");
  791. localStorage.removeItem("menu");
  792. localStorage.removeItem("index");
  793. }
  794. });
  795. }
  796. // 右侧菜单
  797. showLastItems: boolean = false;
  798. // 下拉
  799. fixedMenuXiala() {
  800. this.showLastItems = true;
  801. }
  802. // 上拉
  803. fixedMenuShangla() {
  804. this.showLastItems = false;
  805. }
  806. mainRole: boolean = false; //回到系统管理权限
  807. initRole() {
  808. let menus = JSON.parse(localStorage.getItem("menu"));
  809. console.log("菜单数量" + menus.length);
  810. if (menus.length >= 2) {
  811. this.mainRole = true;
  812. return;
  813. }
  814. }
  815. // 切换右侧菜单Tab
  816. fixedTab: string = "";
  817. checkFixedTab(type: string) {
  818. if (type == "toSystem") {
  819. this.router.navigateByUrl("main");
  820. }
  821. if (this.fixedTab == type) {
  822. this.fixedTab = "";
  823. } else {
  824. this.fixedTab = type;
  825. }
  826. }
  827. //药房端科室切换
  828. changeShow = true;
  829. closeTime = 3;
  830. closeTimeFlag = 0;
  831. hsPromptModalShow: boolean = false; //科室切换提示框是否展示
  832. timerCloseTime = null;
  833. deptDisplay = 1; //护士端是否显示可以别名,1是显示科室名称,2是显示科室别名
  834. //子传父接收
  835. closeModelHs(e) {
  836. this.hsPromptModalShow = JSON.parse(e).show;
  837. this.changeShow = JSON.parse(e).changeShow;
  838. }
  839. //子传父接收
  840. clearModelHs(e) {
  841. if (JSON.parse(e).clear === true) {
  842. clearInterval(this.timerCloseTime);
  843. }
  844. this.changeShow = JSON.parse(e).changeShow;
  845. }
  846. // 头部切换科室
  847. changeKsNow() {
  848. this.hsPromptModalShow = true;
  849. clearInterval(this.timerCloseTime);
  850. this.changeShow = false;
  851. }
  852. // 切换科室
  853. changeKs() {
  854. this.hsPromptModalShow = true;
  855. // (1) 当用户设置为正数时,用户必须查看此窗体指定秒数。
  856. // (2) 当用户设置为负数时,用户可点击知道了也可倒计时自动关闭。
  857. // (3) 如果用户填写0则为无自动关闭和强制查看时间。
  858. if (this.closeTimeFlag === 0) {
  859. return;
  860. }
  861. this.closeTime = Math.abs(this.closeTimeFlag);
  862. clearInterval(this.timerCloseTime);
  863. this.timerCloseTime = setInterval(() => {
  864. this.closeTime = Math.max(--this.closeTime, 0);
  865. if (this.closeTime === 0) {
  866. if (this.closeTimeFlag <= 0) {
  867. this.hsPromptModalShow = false;
  868. }
  869. clearInterval(this.timerCloseTime);
  870. }
  871. }, 1000);
  872. }
  873. promptModalShow:boolean = false;
  874. promptContent:any = null;
  875. ifSuccess:any = null;
  876. promptInfo:any = null;
  877. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  878. showPromptModal(con, success, promptInfo?) {
  879. this.promptModalShow = false;
  880. this.promptContent = con;
  881. this.ifSuccess = success;
  882. this.promptInfo = promptInfo;
  883. setTimeout(() => {
  884. this.promptModalShow = true;
  885. }, 100);
  886. }
  887. }