import { Component, OnInit } from '@angular/core';
import { MyService } from '../my.service';
import { Router,ActivatedRoute } from "@angular/router";
import { LifeCommonService } from "../../common/life-common.service";

@Component({
  selector: 'ydlife-approval-list',
  templateUrl: './approval-list.component.html',
  styleUrls: ['./approval-list.component.scss']
})
export class ApprovalListComponent implements OnInit {
  titleList:Array<any>;
  selectedId:number = 0;
  practitionerId:any;
  approvarList:Array<any>;
  constructor(public lifeCommonService:LifeCommonService,private myService:MyService,private router:Router,private activatedRoute: ActivatedRoute) { }

  ngOnInit() {
    this.practitionerId = JSON.parse(localStorage.getItem('lifeCustomerInfo'))['practitionerId'];
    this.titleList = [
      { id: 0, name: '待审批' },
      { id: 1, name: '通过' },
      { id: 2, name: '拒绝' }
    ]
    this.listQuery();
  }

  selectTab(id) {
    this.selectedId = id;
    this.listQuery();
  }

  listQuery(){
    this.myService.listQuery({practitionerId:this.practitionerId,approvingStatus:this.selectedId}).subscribe((res)=>{
      if(res['success']){
        this.approvarList = res['data']['hiringListInfoList'];
      }else{
        alert(res['message'])  
      }
    })
  }

  jumpToDetail(item,type?:any){
    if(this.selectedId==0){
      sessionStorage.setItem('viewApprovalInfo','0')
    }else{
      sessionStorage.setItem('viewApprovalInfo','1')
    }
    // if(this.selectedId == 0 || type=='view'){
    //   this.router.navigate([`/employee_basic_info`],{queryParams:{hiringBasicInfoId:item.hiringBasicInfoId,approvalIdentity:item.approvalIdentity}})
    // }else{
      this.router.navigate([`/approval_result_list`],{queryParams:{hiringBasicInfoId:item.hiringBasicInfoId,approvalIdentity:true}})

    // }
  }

}
