123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- import { Component, OnInit, AfterViewInit, ElementRef, ViewChild } from '@angular/core';
- import { ToolService } from 'src/app/services/tool.service';
- import { MainService } from 'src/app/services/main.service';
- import { NzMessageService } from 'ng-zorro-antd';
- import { Location } from '@angular/common';
- import { Subject } from 'rxjs';
- import { debounceTime } from 'rxjs/operators';
- import { Router, ActivatedRoute } from '@angular/router';
- @Component({
- selector: 'app-batch-specimen',
- templateUrl: './batch-specimen.component.html',
- styleUrls: ['./batch-specimen.component.less']
- })
- export class BatchSpecimenComponent implements OnInit, AfterViewInit {
- @ViewChild('printBtn', { static: false }) printBtn: ElementRef<HTMLElement>;
- @ViewChild('specimenCodeElement', { static: false}) specimenCodeElementRef: ElementRef;
- constructor(
- private mainService: MainService,
- private tool: ToolService,
- private message: NzMessageService,
- private _location: Location,
- public router: Router,
- private route: ActivatedRoute,
- ) { }
- hosId:any = this.tool.getCurrentHospital().id; //当前院区
- deptDTO:any = this.tool.getCurrentUserDept(); //当前科室
- deptDisplay; //护士端是否显示可以别名,1是显示科室名称,2是显示科室别名
- listOfData: any[] = []; //表格数据
- searchTimerSubject = new Subject(); //防抖
- ngOnInit() {
- //防抖
- this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
- let fun = v[0];
- fun.call(this, v[1]);
- });
- this.tool.getDeptDisplay().subscribe((result) => {
- if (result.status == 200) {
- this.deptDisplay = result.list[0].valueconfig;
- }
- });
- this.init();
- }
- ngAfterViewInit() {
- this.specimenCodeElementRef.nativeElement.focus();
- }
- init(){
- this.getConfig();
- }
- // 获取配置
- configs:any = {};
- getConfig() {
- let postData = {
- idx: 0,
- sum: 10,
- taskTypeConfig: {
- taskTypeDTO: {
- hosId: {
- id: this.hosId
- },
- ordinaryField: {
- key:"ordinary_field",
- value: 'specimenPackage'
- }
- }
- }
- };
- this.mainService
- .getFetchDataList("simple/data", "taskTypeConfig", postData)
- .subscribe((result) => {
- if (result.status == 200) {
- this.configs = result.list[0] || {};
- this.querySaveSpePackage();
- }
- });
- }
- // 获取患者、试管类型列表、标本总数
- total:any;
- typeSpecimentList:any[] = [];
- patientSpecimentList:any[] = [];
- package:any = {};
- maskFlag: any = false;
- querySaveSpePackage(){
- this.maskFlag = this.message.loading("正在加载中..", {
- nzDuration: 0,
- }).messageId;
- let postData:any = {
- deptId: this.deptDTO.id,
- };
- if(this.route.snapshot.queryParams.id){
- postData.packageId = +this.route.snapshot.queryParams.id;
- }
- this.mainService
- .querySaveSpePackage(postData)
- .subscribe((result:any) => {
- this.message.remove(this.maskFlag);
- this.maskFlag = false;
- if (result.state == 200) {
- this.total = result.totalCount;
- this.typeSpecimentList = result.tube || [];
- this.patientSpecimentList = result.patient || [];
- this.package = result.package || {};
- this.getList();
- }
- })
- }
- inspectActiveList: any = [];//选中检查列表
- patientActiveList: any = [];//选中患者列表
- coopData: any = {}; //当前操作列
- btnLoading: boolean = false; //提交按钮loading状态
- delModal: boolean = false; //删除模态框
- tipsMsg1: string; //提示框信息
- tipsMsg2: string; //操作后信息
- confirmDelType: string; //确认的类型(启用/停用,删除)
- showDelModal(
- data,
- tipsMsg1: string,
- tipsMsg2: string,
- type: string,
- ) {
- this.confirmDelType = type;
- this.delModal = true;
- this.coopData = data;
- this.tipsMsg1 = tipsMsg1;
- this.tipsMsg2 = tipsMsg2;
- }
- // 隐藏删除框
- hideDelModal() {
- this.delModal = false;
- this.isShowEndDeptId = false;
- }
- // 确认删除
- confirmDel(e) {
- console.log(e)
- this.btnLoading = true;
- if (this.confirmDelType === "del") {
- //删除-移除标本
- let postData = {
- speIds: this.coopData.id.toString(),
- packageId: this.package.id,
- }
- this.mainService
- .removePackageSpe(postData)
- .subscribe((data:any) => {
- this.btnLoading = false;
- this.delModal = false;
- if (data.state == 200) {
- this.showPromptModal(this.tipsMsg2, true, "");
- } else {
- this.showPromptModal(this.tipsMsg2, false, data.msg);
- }
- });
- }else if (this.confirmDelType === "reset") {
- //先重置再自动清点
- let postData = {
- packageId: this.package.id,
- }
- this.mainService
- .resetPackageSpe(postData)
- .subscribe((data:any) => {
- this.btnLoading = false;
- this.delModal = false;
- if (data.state == 200) {
- this.showPromptModal(this.tipsMsg2, true, "");
- } else {
- this.showPromptModal(this.tipsMsg2, false, data.msg);
- }
- });
- }else if (this.confirmDelType === "package") {
- //打包
- let postData = {
- type: 'specimenPackage',
- id: this.package.id,
- endDeptId: e.endDeptId,
- }
- this.mainService
- .createOrTakeOrderSpecimen(postData)
- .subscribe((data:any) => {
- this.btnLoading = false;
- this.delModal = false;
- this.isShowEndDeptId = false;
- if (data.state == 200) {
- this.printPackage();
- } else {
- this.message.error(data.msg || "操作失败");
- }
- });
- }
- }
- // 打印
- base64:string = '';
- printPackage(){
- this.mainService
- .makeQrCode({}, this.package.packCode)
- .subscribe((data:any) => {
- if (data.state == 200) {
- this.total = data.totalCount;
- this.typeSpecimentList = data.tube || [];
- this.patientSpecimentList = data.patient || [];
- this.package = data.package || {};
- this.base64 = data.base64 || '';
- this.message.success("操作成功");
- setTimeout(()=>{
- this.printBtn.nativeElement.click();
- this.goBack();
- },0)
- } else {
- this.message.error(data.msg || "操作失败");
- }
- });
- }
- // 打包
- isShowEndDeptId:boolean = false;
- packageHandler(){
- this.isShowEndDeptId = true;
- this.getSpePackageEndDeptList();
- }
- // 查询标本包里的所有终点科室
- isShowEndDeptIdArr:any[] = [];
- getSpePackageEndDeptList(){
- this.mainService
- .getSpePackageEndDeptList({packageId: this.package.id})
- .subscribe((data:any) => {
- if (data.state == 200) {
- this.isShowEndDeptIdArr = data.data;
- this.showDelModal({}, `你确认要打包${this.total}只标本吗?`,'打包','package')
- } else {
- this.message.error(data.msg || "操作失败");
- }
- });
- }
- // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
- promptContent: string; //操作提示框提示信息
- ifSuccess: boolean; //操作成功/失败
- promptInfo: string; //操作结果提示信息
- promptModalShow: boolean; //操作提示框是否展示
- showPromptModal(con, success, promptInfo?) {
- this.promptModalShow = false;
- this.promptContent = con;
- this.ifSuccess = success;
- this.promptInfo = promptInfo;
- setTimeout(() => {
- this.promptModalShow = true;
- }, 100);
- this.querySaveSpePackage();
- }
- loading1:boolean = false;
- getList(){
- let data = {
- idx: 0,
- sum: 99999,
- specimen: {
- packageId: this.package ? this.package.id : undefined,
- patientNo: this.activePatientNo || undefined,
- tubeType: this.activeTypeId ? { id: this.activeTypeId } : undefined,
- },
- };
- this.loading1 = true;
- this.mainService
- .getFetchDataList("simple/data", "specimen", data)
- .subscribe((data) => {
- this.loading1 = false;
- if (data.status == 200) {
- this.listOfData = data.list;
- }else{
- this.message.error(data.msg || "请求数据失败");
- }
- });
- }
- // 返回
- goBack(){
- this._location.back();
- }
- // 选择试管类型
- activeTypeId:any;
- clickType(item){
- if(this.activeTypeId == item.id){
- this.activeTypeId = undefined;
- }else{
- this.activeTypeId = item.id;
- }
- this.querySaveSpePackage();
- }
- // 选择患者
- activePatientNo:any;
- clickPatient(item){
- if(this.activePatientNo == item.no){
- this.activePatientNo = undefined;
- }else{
- this.activePatientNo = item.no;
- }
- this.querySaveSpePackage();
- }
- /**
- * @description: PDA扫码复制到文本输入框
- * @return {*}
- * @author: seimin
- */
- specimenCode:string = '';
- inputChange(e){
- if(this.specimenCode.length >= 8){
- this.searchTimer(this.addSpeciment, this.specimenCode);
- }
- }
- // 添加标本
- maskFlag: any = false;
- addSpeciment(speCode){
- this.maskFlag = this.message.loading("正在加载中..", {
- nzDuration: 0,
- }).messageId;
- let postData = {
- speCode,
- packageId: this.package.id,
- };
- this.mainService
- .addPackageSpe(postData)
- .subscribe((result:any) => {
- this.message.remove(this.maskFlag);
- this.maskFlag = false;
- if(result.state == 200){
- this.message.success('操作成功!');
- this.specimenCode = '';//清空
- this.querySaveSpePackage();
- }else{
- this.message.error(result.msg || '操作失败!');
- }
- });
- }
- // 防抖
- searchTimer(fun, e) {
- this.searchTimerSubject.next([fun, e]);
- }
- // 自动清点规则
- isShowPackageSpecimenRule:boolean = false;
- showPackageSpecimenRule(){
- this.isShowPackageSpecimenRule = true;
- }
- // 关闭自动清点规则
- closePackageSpecimenRule(e){
- this.isShowPackageSpecimenRule = e;
- }
- }
|