
import type { TaskNotifyLowerUnits } from '@/dicts/supplierTaskDict';
/**
 * 供应商评价相关接口类型定义
 */

// 模板相关类型
/**
 * 模板查询请求参数
 */
export interface TemplateRequest {
  current?: number;
  pageSize?: number;
  templateName?: string;
  status?: string;
}

/**
 * 模板查询响应
 */
export interface TemplateResponse {
  code: number;
  success: boolean;
  data: {
    records: TemplateItem[];
    total: number;
    size: number;
    current: number;
    pages: number;
  };
  message: string;
}

/**
 * 模板项
 */
export interface TemplateItem {
  id: string;
  templateName: string;
  status: string;
  createTime: string;
  updateTime: string;
  createBy: string;
  updateBy: string;
  [key: string]: any;
}

/**
 * 模板详情响应
 */
export interface TemplateDetailResponse {
  code: number;
  success: boolean;
  data: {
    id: string;
    templateName: string;
    status: string;
    dimensions: TemplateDimension[];
    [key: string]: any;
  };
  message: string;
}

/**
 * 模板维度
 */
export interface TemplateDimension {
  id: string;
  dimensionName: string;
  dimensionWeight: number;
  indicators: TemplateIndicator[];
  [key: string]: any;
}

/**
 * 模板指标
 */
export interface TemplateIndicator {
  id: string;
  indicatorName: string;
  indicatorWeight: number;
  [key: string]: any;
}

/**
 * 新增模板请求
 */
export interface TemplateAddRequest {
  templateName: string;
  dimensions: {
    dimensionName: string;
    dimensionWeight: number;
    indicators: {
      indicatorName: string;
      indicatorWeight: number;
    }[];
  }[];
}

/**
 * 更新模板请求
 */
export interface TemplateUpdateRequest {
  id: string;
  templateName: string;
  dimensions: {
    id?: string;
    dimensionName: string;
    dimensionWeight: number;
    indicators: {
      id?: string;
      indicatorName: string;
      indicatorWeight: number;
    }[];
  }[];
}

// 品类相关类型
/**
 * 品类树响应
 */
export interface CategoryTreeResponse {
  code: number;
  success: boolean;
  data: CategoryTreeItem[];
  message: string;
}

/**
 * 品类树节点
 */
export interface CategoryTreeItem {
  id: string;
  name: string;
  children?: CategoryTreeItem[];
  [key: string]: any;
}

// 任务相关类型
/**
 * 任务查询请求
 */

  // 供应商评价任务记录类型
  export interface TaskRecord {
    id: string;
    taskName: string;
    taskCode: string;
    taskType: string;
    templateName: string;
    status: string;
    startTime: string;
    endTime: string;
    createBy: string;
    createTime: string;
    updateBy?: string;
    updateTime?: string;
    key?: string;
  }
export interface TaskRequest {
  current?: number;
  pageSize?: number;
  evaluateTheme?: string;
  evaluateYear?: string;
  startTime?: string;
  endTime?: string;
  categoryId?: string;
  status?: string;
}
// 供应商评价任务查询参数
export interface TaskSearchParams {
  basePageRequest: API.BasePageRequest;
  evaluateTheme?: string;
  status?: string;
  dateRange?: string[];
  startTime?: string;
  endTime?: string;
}

/**
 * 任务查询响应
 */
export interface TaskResponse {
  code: number;
  success: boolean;
  data: {
    records: TaskItem[];
    total: number;
    size: number;
    current: number;
    pages: number;
  };
  message: string;
}

/**
 * 任务项
 */
export interface TaskItem {
  id: string;
  evaluateTheme: string;
  evaluateYear: string;
  startTime: string;
  endTime: string;
  templateId: string;
  templateName: string;
  status: string;
  categoryId?: string;
  categoryName?: string;
  createTime: string;
  createBy: string;
  [key: string]: any;
}


// 评价结果相关类型
/**
 * 评价任务请求
 */
export interface EvaluateTaskRequest {
  current?: number;
  pageSize?: number;
  evaluateTheme?: string;
  evaluateYear?: string;
  startTime?: string;
  endTime?: string;
  status?: string;
}

/**
 * 评价任务数据
 */
export interface EvaluateTaskData {
  records: EvaluateTaskItem[];
  total: number;
  size: number;
  current: number;
  pages: number;
}

/**
 * 评价任务项
 */
export interface EvaluateTaskItem {
  id: string;
  evaluateTheme: string;
  evaluateYear: string;
  startTime: string;
  endTime: string;
  templateId: string;
  templateName: string;
  status: string;
  createTime: string;
  createBy: string;
  supplierCount: number;
  [key: string]: any;
}

/**
 * 评价供应商请求
 */
export interface EvaluateSupplierRequest {
  current?: number;
  pageSize?: number;
  taskId: string;
  supplierName?: string;
  status?: string;
}

/**
 * 评价供应商数据
 */
export interface EvaluateSupplierData {
  records: EvaluateSupplierItem[];
  total: number;
  size: number;
  current: number;
  pages: number;
}

/**
 * 评价供应商项
 */
export interface EvaluateSupplierItem {
  id: string;
  supplierId: string;
  supplierName: string;
  socialCreditCode: string;
  status: string;
  score: number;
  level: string;
  [key: string]: any;
}

/**
 * 评价分数请求
 */
export interface EvaluateScoreRequest {
  current?: number;
  pageSize?: number;
  taskId: string;
  supplierId: string;
}

/**
 * 评价分数详情数据
 */
export interface EvaluateScoreDetailData {
  id: string;
  supplierId: string;
  supplierName: string;
  taskId: string;
  evaluateTheme: string;
  evaluateYear: string;
  dimensions: EvaluateDimension[];
  userScore: number;
  totalScore: number;
  level: string;
  [key: string]: any;
}

/**
 * 评价维度
 */
export interface EvaluateDimension {
  id: string;
  dimensionName: string;
  dimensionWeight: number;
  dimensionScore: number;
  indicators: EvaluateIndicator[];
  [key: string]: any;
}

/**
 * 评价指标
 */
export interface EvaluateIndicator {
  id: string;
  indicatorName: string;
  indicatorWeight: number;
  score: number;
  remarks: string;
  [key: string]: any;
}

// 评价规则相关类型
/**
 * 评价规则响应
 */
export interface EvaluateRuleResponse {
  code: number;
  success: boolean;
  data: EvaluateRuleItem[];
  message: string;
}

/**
 * 评价规则项
 */
export interface EvaluateRuleItem {
  id: string;
  levelName: string;
  minScore: number;
  maxScore: number;
  status: string;
  createTime: string;
  updateTime: string;
  createBy: string;
  updateBy: string;
  [key: string]: any;
}

/**
 * 评价规则详情响应
 */
export interface EvaluateRuleDetailResponse {
  code: number;
  success: boolean;
  data: EvaluateRuleItem;
  message: string;
}

/**
 * 评价规则新增请求
 */
export interface EvaluateRuleAddRequest {
  levelName: string;
  minScore: number;
  maxScore: number;
}

/**
 * 评价规则更新请求
 */
export interface EvaluateRuleUpdateRequest {
  id: string;
  levelName: string;
  minScore: number;
  maxScore: number;
}

/**
 * 供应商评价任务详情接口类型定义
 */
export interface IndicatorItem {
  indicatorIds: string[];
  type: number;
  userId: string;
}

/*
人员信息
*/
export interface PersonnelItem {
  id: string;
  name: string;
  userId: string;
  userName: string;
  position: string;
  userDept: string;
  userDeptId: string;
  indicatorIds?: string[];
}
/**
 * 任务详情数据
 */
export interface TaskDetailData {
  categoryId: string | null;
  categoryLimitation: string | null;
  createBy: string | null;
  createDate: string | null;
  createTime: string | null;
  deleteFlag: string | null;
  delFlag: string;
  deptId: string | null;
  endTime: string | null;
  evaluateTheme: string | null;
  evaluateYear: string | null;
  id: string | null;
  indicatorList: IndicatorItem[] | null;
  lastUpdateTime: string | null;
  startTime: string | null;
  status: string;
  supplierIds: {
    id: string;
    userIds: string[];
  }[] | null;
  userList: PersonnelItem[];
  suppliers: {
    id: string;
    supplierName: string;
    socialCreditCode?: string;
    category?: string;
    department?: string;
    evaluators: {
      id: string;
      name: string;
      department: string;
      position?: string;
    }[];
    [key: string]: any;
  }[] | null;
  templateId: string | null;
  tenantId: string | null;
  tenantName: string | null;
  updateBy: string | null;
  updateDate: string | null;
  updateTime: string | null;
  weightDept: string | null;
  weightStatus: number | null;
  weightValue: string | null;
  taskDeptWeightList: DeptWeightItem[] | null;
  blackSupplierVos: {
    deptName: string;
    supplierId: string;
    supplierName: string;
    userList: PersonnelItem[];
  }[],
  [property: string]: any;
}
// 部门配置权重
export interface DeptWeightItem {
  //部门id
  weightDept: string;
  // 部门权重值
  weightValue: string;
  // 部门名称
  weightDeptName: string;
}
/**
 * 任务详情响应
 */
export interface TaskDetailResponse {
  code: number;
  data: TaskDetailData;
  message: string;
  success: boolean;
  [property: string]: any;
}

// 新增评价任务和修改 请求参数定义
export type TaskAddRequest = {
  id?: string;
  /**
   * 品类限制类型（0.通用不限品类、1.限制品类）
   */
  categoryLimitation?: string;
  /**
   * 评价结束时间
   */
  endTime: string;
  /**
   * 评价主题
   */
  evaluateTheme: string;
  /**
   * 评价年度
   */
  evaluateYear: string;
  indicatorList: IndicatorItem[];
  /**
   * 评价开始时间
   */
  startTime: string;
  supplierIds: SupplierId[];
  taskDeptWeightList: DeptWeightItem[];
  /**
   * 评价表模板id(cosco_evaluate_template表主键)
   */
  templateId: string;
  // 品类id
  categoryId?: string;
  /**
 * 是否下级部门可以添加评价信息   0否1是
 */
  taskStatus?: TaskNotifyLowerUnits | null;
  /*
  供应商列表
  */
    selectedSuppliers?: SupplierItem[];
    userList?: PersonnelItem[];
}
/**
 * 供应商项
 */
export interface SupplierItem {
  id: string;                       // 供应商ID
  supplierName: string;             // 供应商名称
  supplierId?: string;                    // 供应商ID
  socialCreditCode?: string;        // 统一社会信用代码
  category?: string;                // 品类
  department?: string;              // 准入部门
  evaluatorCount?: number;           // 评价人员数量
  evaluators: PersonnelItem[];      // 评价人员列表
  deptName?: string;        // 部门名称
  // 其他可能的字段
  [key: string]: any;
}
export type SupplierId = {
  /**
   * 供应商id
   */
  id: string;
  /**
   * 用户集合
   */
  userIds?: string[];
}
