import { Component, ViewContainerRef } from '@angular/core';
import { NonNullableFormBuilder } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalService } from 'ng-zorro-antd/modal';
import { CommonNzModule } from '../../../../common.nz.module';
import { ApiService } from '../../../../services/api.service';
import { BasicDataService } from '../../../../services/basic.service';
import { KnowledgeService } from '../../../../services/knowledge.service';
import { SettingService } from '../../../../services/setting.service';
import { EquipmentComponent } from './equipment/equipment.component';
import { OperationComponent } from './operation/operation.component';
import { PositionComponent } from './position/position.component';

export enum PoeType {
  Position = 1,
  Operation = 2,
  Equipment = 3,
}
export const poeTabs = [
  {
    label: '场所',
    value: PoeType.Position,
  },
  {
    label: '作业',
    value: PoeType.Operation,
  },
  {
    label: '设备',
    value: PoeType.Equipment,
  },
];

/**
 * 基础数据 - 场所/作业/设备
 */
@Component({
  selector: 'basic-poe',
  standalone: true,
  imports: [CommonNzModule, PositionComponent, OperationComponent, EquipmentComponent],
  templateUrl: './poe.component.html',
  styleUrl: './poe.component.less',
})
export class PoeComponent {
  poeTabs = poeTabs;
  activeTab = PoeType.Position;

  loading = false;
  constructor(
    private fb: NonNullableFormBuilder,
    private viewContainerRef: ViewContainerRef,
    private modal: NzModalService,
    private knowledge: KnowledgeService,
    private basic: BasicDataService,
    private setting: SettingService,
    private message: NzMessageService,
    private api: ApiService
  ) {}
  ngOnInit() {}
  ngOnDestroy() {}

  activeTabChange(value: number) {
    this.activeTab = value;
  }

  get company() {
    return this.setting.userCompany;
  }
  get currentTab() {
    return this.poeTabs.find(t => t.value === this.activeTab);
  }
  get currentTabLabel() {
    return this.currentTab?.label;
  }
}
