import { Component, EventEmitter, Input, Output } from '@angular/core';
import { CommonNzModule } from '../../../../../common.nz.module';
import { BasicDataService } from '../../../../../services/basic.service';
import { KnowledgeService } from '../../../../../services/knowledge.service';
import { DataEmptyComponent } from '../../../../../shared/data-empty/data-empty.component';
import { ScrollImagesComponent } from '../../../../../shared/scroll-images/scroll-images.component';
import { DetailHeaderComponent } from './detail-header/detail-header.component';
import { HandleAcceptanceComponent } from './handle-acceptance/handle-acceptance.component';
import { HandleProgressComponent } from './handle-progress/handle-progress.component';

interface FlowItem {
  title: string;
  creator: string;
  createTime: string;
  status: string;
  action: string;
}

interface ActionConfig {
  title: string;
  activeColor: string;
  icon: string;
}
const flowActionMap: Record<string, ActionConfig> = {
  submit: {
    title: '提交问题',
    activeColor: '#2953E8',
    icon: 'icons:hazard/submit',
  },
  audit: {
    title: '审隐患核',
    activeColor: '#DF0000',
    icon: 'icons:hazard/audit',
  },
  plan: {
    title: '治理方案',
    activeColor: '#FA642A',
    icon: 'icons:hazard/plan',
  },
  planAudit: {
    title: '方案审核',
    activeColor: '#01C49B',
    icon: 'icons:hazard/plan-audit',
  },
};

@Component({
  selector: 'hazard-detail',
  standalone: true,
  imports: [
    CommonNzModule,
    DetailHeaderComponent,
    DataEmptyComponent,
    ScrollImagesComponent,
    HandleProgressComponent,
    HandleAcceptanceComponent,
  ],
  templateUrl: './detail.component.html',
  styleUrl: './detail.component.less',
  host: {
    class: 'custom-scroll-bar',
  },
})
export class HazardDetailComponent {
  @Input() data: Hazard.HazardDto = {} as Hazard.HazardDto;
  @Output() onClose = new EventEmitter<void>();

  flowList: FlowItem[] = [
    {
      title: '提交问题',
      creator: '张三',
      createTime: '2024-01-01 12:00',
      status: 'submit',
      action: 'submit',
    },
    {
      title: '审隐患核',
      creator: '李四',
      createTime: '2024-01-01 12:00',
      status: 'audit',
      action: 'audit',
    },
    {
      title: '治理方案',
      creator: '王五',
      createTime: '2024-01-01 12:00',
      status: 'plan',
      action: 'plan',
    },
    {
      title: '方案审核',
      creator: '赵六',
      createTime: '2024-01-01 12:00',
      status: 'planAudit',
      action: 'planAudit',
    },
  ];
  constructor(
    private knowledge: KnowledgeService,
    private basic: BasicDataService
  ) {}

  getIcon(item: FlowItem) {
    return flowActionMap[item.action]?.icon;
  }
  getIconColor(item: FlowItem) {
    return flowActionMap[item.action]?.activeColor || '#A5A5A5';
  }
}
