import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { MainService } from '../../services/main.service';

@Component({
  selector: 'app-blood-history-prompt-modal',
  templateUrl: './blood-history-prompt-modal.component.html',
  styleUrls: ['./blood-history-prompt-modal.component.less']
})
export class BloodHistoryPromptModalComponent implements OnInit {
  // 切换科室，切换弹窗
  hsLoading = false;
  historyLogsList: any = [];
  historySpecimenPageIndex: number = 1;//表格当前页码
  historySpecimenPageSize: number = 5;//表格每页展示条数
  historyLogsListLength: number = 10;//表格总数据量
  @Input() show: Boolean;
  @Input() bloodId: String | Number;

  @Output() closeModelHs = new EventEmitter<any>();//1.组件暴露一个 EventEmitter 属性，当事件发生时，子组件利用该属性 emits(向上弹射)事件

  constructor(private mainService: MainService) { }

  ngOnInit() {
    this.getHistorySpecimen();
  }
  // 关闭弹窗
  hideModal() {
    this.closeModelHs.emit(JSON.stringify({ show: false }));//emits(向上弹射)事件
  }
  // 获取列表数据
  getHistorySpecimen(idx?) {
    if (idx) {
      this.historySpecimenPageIndex = 1;
    }
    this.hsLoading = true;
    this.mainService.getFetchData('simple/data','blood', this.bloodId).subscribe(data => {
      this.hsLoading = false;
      this.historyLogsList = data.data ? data.data.logs : [];
      this.historyLogsListLength = data.totalNum || 0;
    })
  }
}



