import { Component, OnInit, AfterViewInit } from "@angular/core";
import { Location } from '@angular/common';

@Component({
  selector: "app-incident-config",
  templateUrl: "./incident-config.component.html",
  styleUrls: ["./incident-config.component.less"],
})
export class IncidentConfigComponent implements OnInit, AfterViewInit {
  constructor(
    private _location: Location,
  ){}

  // tab
  tagList:any = [
    // { id: 1, title: '故障现象',},
    // { id: 2, title: '优先级',},
    // { id: 3, title: '数据字典',},
    // { id: 4, title: '消息通知',},
		// { id: 5, title: '工时管理',},
		// { id: 6, title: '科室绑定人员',},
    // { id: 7, title: '院区配置',},
  ];

  // 数据字典
  dictionaryKeyList:any[] = [
    { id: 1, name: '积分配置', key: "incident_category_score"},
    { id: 2, name: '报修来源', key: "incident_source"},
    { id: 3, name: '处理结果', key: "incident_closecode"},
    { id: 4, name: '处理方式', key: "incident_handle_type"},
    { id: 5, name: '状态', key: "incident_status"},
    { id: 6, name: '维修记录', key: "repair_type"},
    { id: 7, name: '满意度评价', key: "incident_degree"},
		{ id: 8, name: '告警紧急度', key: "alarm_urgency"},
  ]

  // 院区配置
  hospitalTabList:any[] = [
    { id: 1, name: '资产及耗材', key: "asset_consumables"},
    { id: 2, name: '评价', key: "evaluation"},
		{ id: 3, name: '告警自动建单', key: "alarm"},
  ]
	
	// 自动建单
	voluntarilyTabList:any[] = [
	  { id: 1, name: '告警建单', key: "alarmConfig"},
	]
  ngOnInit(): void {}

  ngAfterViewInit(){
    setTimeout(() => {
      let menus = JSON.parse(localStorage.getItem("menu"));
      let incidentConfig = menus.find(item => item.link == 'incidentConfig');
      this.tagList = incidentConfig ? (incidentConfig.childrens || []) : [];
      this.tagList.length && this.clickTag(this.tagList[0]);
    }, 0)
  }

  // 点击tab
  activeTagLink:any;
  clickTag(tag){
    this.activeTagLink = tag.link;
  }

  // 返回
  goBack(){
    this._location.back();
  }
}
