import { Component } from '@angular/core';
import { CommonNzModule } from '../../../../../common.nz.module';
import { WorkbenchTabsComponent } from '../../../../../shared/workbench-tabs/workbench-tabs.component';
import { ListItem, ListItemComponent } from './list-item/list-item.component';

const getMockItem = (index: number): ListItem => {
  return {
    name: `XXX${index + 1}风险名称`,
    category: '八防措施',
    type: '触电伤害',
    level: 'R2',
    spot: '6号线',
    equipment: '接触网',
    result: '人身伤亡',
    department: 'XXX部门',
    responsible: '王甜甜',
  };
};

@Component({
  selector: 'workbench-my-listing',
  standalone: true,
  imports: [CommonNzModule, WorkbenchTabsComponent, ListItemComponent],
  templateUrl: './listing.component.html',
  styleUrl: './listing.component.less',
})
export class ListingComponent {
  tabs = ['风险清单', '隐患清单'];
  activeTab = this.tabs[0];

  typeOptions = [
    { label: '处置中问题', value: 'processing' },
    { label: '所有问题', value: 'all' },
  ];
  type = this.typeOptions[0].value;

  levelOptions: Option[] = [
    { label: '全部', value: 'all' },
    { label: 'R1', value: 'R1' },
    { label: 'R2', value: 'R2' },
    { label: 'R2*', value: 'R2*' },
    { label: 'R3', value: 'R3' },
    { label: 'R4', value: 'R4' },
  ];
  level: string | number = this.levelOptions[0].value;

  changeLevel(value: string | number) {
    this.level = value;
  }
  changeType(value: string) {
    this.type = value;
  }

  list: ListItem[] = Array.from({ length: 10 }).map((_, index) => getMockItem(index));
}
