import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { MainService } from '../../services/main.service'; import { ToolService } from 'src/app/services/tool.service'; import { format, startOfDay, endOfDay } from 'date-fns'; @Component({ selector: 'app-businessData-detail-modal', templateUrl: './businessData-detail-modal.component.html', styleUrls: ['./businessData-detail-modal.component.less'] }) export class BusinessDataDetailModalComponent implements OnInit { // 切换科室,切换弹窗 hosId; hsLoading = false; bloodList: any = [];// 血制品列表 specimenList: any = [];// 标本列表 inspectionRateStatisticsList: any = [];// 科室检查率统计列表 pageIndex: number = 1;//表格当前页码 pageSize: number = 5;//表格每页展示条数 total: number = 0;//表格总数据量 searchCriteria:any = { stype: 0, specimenDesc: 0, } @Input() show: Boolean; @Input() orderId: String; @Input() type: String = ''; @Input() dataInfo: any; @Output() closeModelHs = new EventEmitter();//1.组件暴露一个 EventEmitter 属性,当事件发生时,子组件利用该属性 emits(向上弹射)事件 constructor(private mainService: MainService, private tool: ToolService) { } ngOnInit() { this.hosId = this.tool.getCurrentHospital().id; this.tabType = 1; switch(this.type){ case 'blood': this.getBlood(1); break; case 'specimen': this.getSpecimen(1); this.getSpecimenType(); this.getSpecimenDesc(); break; case 'deptInspectionRateStatistics': this.getDeptInspectionRateStatistics(1); break; } } // 关闭弹窗 hideModal() { this.closeModelHs.emit(JSON.stringify({ show: false }));//emits(向上弹射)事件 } // 切换tab栏 tabType: number = 1; //tab栏 checkTab(type) { this.tabType = type; } // 切换标本类型下拉框 selectStype(e){ console.log(e); this.searchCriteria.specimenDesc = 0; this.getSpecimenDesc(); this.getSpecimen(1); } // 切换标本类型下拉框 selectDesc(e){ console.log(e); this.getSpecimen(1); } // 分页获取数据 getList(){ switch(this.type){ case 'blood': this.getBlood(); break; case 'specimen': this.getSpecimen(); break; case 'deptInspectionRateStatistics': this.getDeptInspectionRateStatistics(); break; } } // 获取列表数据 getBlood(idx?) { if (idx) { this.pageIndex = 1; } let postData = { "type": "blood", "orderId": this.orderId } this.hsLoading = true; this.mainService.checkData(postData).subscribe((data:any) => { this.hsLoading = false; this.bloodList = data.data ? data.data.all : []; this.pageSize = this.total = data.data ? data.data.all.length : 0; }) } // 获取标本类型 specimentTypeList: any[] = [{ id: 0, name: '全部' }]; getSpecimenType() { this.mainService.getDictionary("list", "specimen_type").subscribe((data:any) => { let specimentTypeList = [{ id: 0, name: '全部' }]; this.specimentTypeList = specimentTypeList.concat(data); }) } // 获取检验项目 specimenDescList: any[] = [{ id: 0, name: '', nameNum: '全部' }]; id:number = 0; getSpecimenDesc() { let postData = { "hosId": this.hosId, "gdId": this.orderId, "stype": this.searchCriteria.stype || undefined, }; this.mainService.specimenCount(postData).subscribe((data:any) => { data.data = data.data || []; let specimenDescList:any = [{ id: 0, name: '全部', nameNum: '全部' }]; specimenDescList[0].nameNum = `全部(${data.total})`; this.specimenDescList = specimenDescList.concat( data.data.map(v => ({id: --this.id, name: v[0] || '', nameNum: (v[0] ? v[0].slice(0, 15) + (v[0].length >= 15 ? '...' : '') : '') + `(${v[1]})`}))); }) } // 获取标本列表 getSpecimen(idx?) { if (idx) { this.pageIndex = 1; } let postData = { idx: this.pageIndex - 1, sum: this.pageSize, specimen: { orderBy: 'arrive_time desc', hosId: this.hosId, gdid: this.orderId, stype: this.searchCriteria.stype ? { id: this.searchCriteria.stype } : undefined, specimenDesc: this.searchCriteria.specimenDesc ? this.specimenDescList.find(v => v.id == this.searchCriteria.specimenDesc).name: undefined, } } this.hsLoading = true; this.mainService.getFetchDataList('simple/data','specimen',postData).subscribe(data => { this.hsLoading = false; this.specimenList = data.list || []; this.total = data.totalNum || 0; }) } // 获取科室检查率统计-详情列表 getDeptInspectionRateStatistics(idx?) { if (idx) { this.pageIndex = 1; } let postData:any = { idx: this.pageIndex - 1, sum: this.pageSize, } switch(this.dataInfo.type){ case 'total': postData.deptId = this.dataInfo.data.deptId; postData.hosId = this.hosId; postData.startTime = this.dataInfo.searchDto.dateRange[0] ? format(startOfDay(this.dataInfo.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : undefined; postData.endTime = this.dataInfo.searchDto.dateRange[1] ? format(endOfDay(this.dataInfo.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : undefined; break; case 'noCheckCount': postData.deptId = this.dataInfo.data.deptId; postData.hosId = this.hosId; postData.startTime = this.dataInfo.searchDto.dateRange[0] ? format(startOfDay(this.dataInfo.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : undefined; postData.endTime = this.dataInfo.searchDto.dateRange[1] ? format(endOfDay(this.dataInfo.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : undefined; postData.reportInsState = 'noCheck'; break; case 'checkCount': postData.deptId = this.dataInfo.data.deptId; postData.hosId = this.hosId; postData.startTime = this.dataInfo.searchDto.dateRange[0] ? format(startOfDay(this.dataInfo.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : undefined; postData.endTime = this.dataInfo.searchDto.dateRange[1] ? format(endOfDay(this.dataInfo.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : undefined; postData.reportInsState = 'check'; break; case 'insCount': postData.deptId = this.dataInfo.data.deptId; postData.hosId = this.hosId; postData.startTime = this.dataInfo.searchDto.dateRange[0] ? format(startOfDay(this.dataInfo.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : undefined; postData.endTime = this.dataInfo.searchDto.dateRange[1] ? format(endOfDay(this.dataInfo.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : undefined; postData.reportInsState = 'inspect'; break; } this.hsLoading = true; this.mainService.listMsgByMain("listInspect", postData).subscribe((data: any) => { this.hsLoading = false; this.inspectionRateStatisticsList = data.list || []; this.total = data.totalNum || 0; }) } }