import dayjs from 'dayjs';
import { levelMap } from '../../../../app.util';

const getRandomLevel = () => {
  return Object.keys(levelMap)[Math.floor(Math.random() * Object.keys(levelMap).length)];
};

const getMockItem = (id: number): Knowledge.RiskItem => ({
  id,
  company: `公司${id}`,
  type: id,
  category: id,
  title: `风险项${id}`,
  consequences: [id, id + 1],
  level: getRandomLevel(),
  involvedPositions: [id],
  involvedOperations: [id],
  involvedEquipments: [id],
  responsiblePositions: [id],
  associations: [
    {
      title: `关联标题${id}`,
      content: `关联内容${id}`,
      consequence: `关联后果${id}`,
    },
  ],
  regulations: [id],
  requirement: `主要作业要求${id}`,
  otherMeasure: `其他措施${id}`,
  responsiblePerson: `责任人${id}`,
  specificUnit: `具体单位${id}`,
  status: 1,
  updateReason: `更新原因${id}`,
  updatedDate: dayjs().format('YYYY-MM-DD HH:mm'),
});

export const getMockList = (count: number): Knowledge.RiskItem[] => {
  return Array.from({ length: count }, (_, index) => getMockItem(index + 1));
};
