import { Component, OnInit, Output, Input } from '@angular/core';
import { EventEmitter } from '@angular/core';
import { Router } from "@angular/router";

@Component({
  selector: 'app-select-menu',
  templateUrl: './select-menu.component.html',
  styleUrls: ['./select-menu.component.less']
})
export class SelectMenuComponent implements OnInit {
  @Output() cancelMenuModal = new EventEmitter();
  @Input() iShowMenuModal: boolean = false;//模态框
  allHospital: any;//所有院区
  hosLoading: boolean = false;//确定按钮的loading
  configurationCenterMenus: any[] = [];//配置中心菜单
  constructor(
    private router: Router,
  ) { }

  ngOnInit() {
    let menus = JSON.parse(localStorage.getItem("menu"));
    let configurationCenterMenus = [];
    // 事件配置
    let incidentConfig = menus.find(item => item.link == 'incidentConfig');
    incidentConfig && configurationCenterMenus.push(incidentConfig);
    // 三方配置
    let otherConfig = menus.find(item => item.link == 'otherConfig');
    otherConfig && configurationCenterMenus.push(otherConfig);
		// 系统配置
		let systemConfig = menus.find(item => item.link == 'systemConfig');
		systemConfig && configurationCenterMenus.push(systemConfig);
    // 业务页面控制
    let pageConfig = menus.find(item => item.link == 'pageConfig');
    pageConfig && configurationCenterMenus.push(pageConfig);
    // 护士端配置控制
    let nurseConfig = menus.find(item => item.link == 'nurseConfig');
    nurseConfig && configurationCenterMenus.push(nurseConfig);
    this.configurationCenterMenus = configurationCenterMenus;
		// 数据生成
		let dataGenerate = menus.find(item => item.link == 'dataGenerate');
		dataGenerate && configurationCenterMenus.push(dataGenerate);
  }
  clickHandle(item){
    this.router.navigateByUrl(item.link);
  }
  // 隐藏模态框
  hideModal() {
    this.cancelMenuModal.emit(false)
  }
}
