import type { VxeGridProps } from '#/adapter/vxe-table';
import type { FormSchemaGetter } from '#/adapter/form';

// 安全检查报表类型定义
export interface SecurityCheckData {
  id: number;
  taskName: string; // 任务名称
  area: string; // 片区
  station: string; // 油站
  totalIssues: number; // 异常总数
  noPhotosCount: number; // 无拍照数
  executor: string; // 执行人
  position: string; // 岗位
  comment: string; // 评论
  deadline: string; // 截止时间
  processingTime: string; // 处理时间
  completionStatus: string; // 完成状态
  creator: string; // 创建人
}

// 安全检查报表表格配置
export const tableColumns: VxeGridProps['columns'] = [
  { title: '任务名称', field: 'taskName', minWidth: 150, align: 'center' },
  { title: '油站', field: 'station', minWidth: 150, align: 'center' },
  { title: '异常总数', field: 'totalIssues', minWidth: 100, align: 'center' },
  { title: '无拍照数', field: 'noPhotosCount', minWidth: 100, align: 'center' },
  { title: '执行人', field: 'executor', minWidth: 120, align: 'center' },
  { title: '岗位', field: 'position', minWidth: 120, align: 'center' },
  { title: '评论', field: 'comment', minWidth: 150, align: 'center' },
  { title: '截止时间', field: 'deadline', minWidth: 150, align: 'center' },
  { title: '处理时间', field: 'processingTime', minWidth: 150, align: 'center' },
  { title: '完成状态', field: 'completionStatus', minWidth: 120, align: 'center' },
  { title: '创建人', field: 'creator', minWidth: 120, align: 'center' },
  { 
    title: '操作', 
    field: 'action', 
    minWidth: 120, 
    align: 'center', 
    slots: { default: 'action' }
  },
];

// 完成状态选项
export const completionStatusOptions = [
  { label: '已完成', value: '已完成' },
  { label: '未完成', value: '未完成' },
  { label: '进行中', value: '进行中' },
];

// 岗位选项
export const positionOptions = [
  { label: '站长', value: '站长' },
  { label: '安全员', value: '安全员' },
  { label: '加油员', value: '加油员' },
  { label: '收银员', value: '收银员' },
];

// 评论选项
export const commentOptions = [
  { label: '已评论', value: '已评论' },
  { label: '未评论', value: '未评论' },
];

// 创建人选项
export const creatorOptions = [
  { label: '管理员', value: '管理员' },
  { label: '张三', value: '张三' },
  { label: '李四', value: '李四' },
  { label: '王五', value: '王五' },
];

// 片区选项
export const areaOptions = [
  { label: '片区1', value: '片区1' },
  { label: '片区2', value: '片区2' },
  { label: '片区3', value: '片区3' },
  { label: '片区4', value: '片区4' },
];

// 油站选项
export const stationOptions = [
  { label: '北京东加油站', value: '北京东加油站' },
  { label: '北京西加油站', value: '北京西加油站' },
  { label: '北京南加油站', value: '北京南加油站' },
  { label: '北京北加油站', value: '北京北加油站' },
  { label: '机场油站', value: '机场油站' },
  { label: '未来路加油站', value: '未来路加油站' },
  { label: '龙飞虎加油站', value: '龙飞虎加油站' },
  { label: '法站加油站', value: '法站加油站' },
];

// 安全检查报表虚拟数据
export const SECURITY_CHECK_MOCK_DATA: SecurityCheckData[] = [
  { 
    id: 1, 
    taskName: '安全检查任务1', 
    area: '片区1', 
    station: '北京东加油站', 
    totalIssues: 15, 
    noPhotosCount: 3, 
    executor: '张三', 
    position: '站长', 
    comment: '已评论', 
    deadline: '2025-12-31', 
    processingTime: '2025-12-15 09:30:00', 
    completionStatus: '已完成', 
    creator: '管理员'
  },
  { 
    id: 2, 
    taskName: '安全检查任务2', 
    area: '片区1', 
    station: '北京西加油站', 
    totalIssues: 8, 
    noPhotosCount: 1, 
    executor: '李四', 
    position: '安全员', 
    comment: '已评论', 
    deadline: '2025-12-31', 
    processingTime: '2025-12-15 10:00:00', 
    completionStatus: '已完成', 
    creator: '张三'
  },
  { 
    id: 3, 
    taskName: '安全检查任务3', 
    area: '片区2', 
    station: '机场油站', 
    totalIssues: 22, 
    noPhotosCount: 5, 
    executor: '王五', 
    position: '加油员', 
    comment: '未评论', 
    deadline: '2025-12-31', 
    processingTime: '2025-12-15 14:20:00', 
    completionStatus: '进行中', 
    creator: '李四'
  },
  { 
    id: 4, 
    taskName: '安全检查任务4', 
    area: '片区2', 
    station: '北京南加油站', 
    totalIssues: 10, 
    noPhotosCount: 2, 
    executor: '赵六', 
    position: '收银员', 
    comment: '已评论', 
    deadline: '2025-12-31', 
    processingTime: '2025-12-15 08:45:00', 
    completionStatus: '已完成', 
    creator: '王五'
  },
  { 
    id: 5, 
    taskName: '安全检查任务5', 
    area: '片区3', 
    station: '北京北加油站', 
    totalIssues: 18, 
    noPhotosCount: 4, 
    executor: '钱七', 
    position: '安全员', 
    comment: '未评论', 
    deadline: '2025-12-31', 
    processingTime: '2025-12-15 15:30:00', 
    completionStatus: '未完成', 
    creator: '管理员'
  },
  { 
    id: 6, 
    taskName: '安全检查任务6', 
    area: '片区3', 
    station: '未来路加油站', 
    totalIssues: 12, 
    noPhotosCount: 2, 
    executor: '孙八', 
    position: '站长', 
    comment: '已评论', 
    deadline: '2025-12-31', 
    processingTime: '2025-12-15 11:15:00', 
    completionStatus: '已完成', 
    creator: '张三'
  },
  { 
    id: 7, 
    taskName: '安全检查任务7', 
    area: '片区4', 
    station: '龙飞虎加油站', 
    totalIssues: 25, 
    noPhotosCount: 6, 
    executor: '周九', 
    position: '加油员', 
    comment: '未评论', 
    deadline: '2025-12-31', 
    processingTime: '2025-12-15 13:40:00', 
    completionStatus: '进行中', 
    creator: '李四'
  },
  { 
    id: 8, 
    taskName: '安全检查任务8', 
    area: '片区4', 
    station: '法站加油站', 
    totalIssues: 9, 
    noPhotosCount: 1, 
    executor: '吴十', 
    position: '收银员', 
    comment: '已评论', 
    deadline: '2025-12-31', 
    processingTime: '2025-12-15 09:10:00', 
    completionStatus: '已完成', 
    creator: '王五'
  },
];

// 生成更多模拟数据，共20条
for (let i = 9; i <= 20; i++) {
  const randomArea = areaOptions[Math.floor(Math.random() * areaOptions.length)].value;
  const randomStation = stationOptions[Math.floor(Math.random() * stationOptions.length)].value;
  const randomCompletionStatus = completionStatusOptions[Math.floor(Math.random() * completionStatusOptions.length)].value;
  const randomPosition = positionOptions[Math.floor(Math.random() * positionOptions.length)].value;
  const randomComment = commentOptions[Math.floor(Math.random() * commentOptions.length)].value;
  const randomCreator = creatorOptions[Math.floor(Math.random() * creatorOptions.length)].value;
  
  SECURITY_CHECK_MOCK_DATA.push({
    id: i,
    taskName: `安全检查任务${i}`,
    area: randomArea,
    station: randomStation,
    totalIssues: Math.floor(Math.random() * 30) + 5,
    noPhotosCount: Math.floor(Math.random() * 10),
    executor: `${['张', '李', '王', '赵', '钱'][Math.floor(Math.random() * 5)]}${['一', '二', '三', '四', '五', '六', '七', '八', '九', '十'][Math.floor(Math.random() * 10)]}`,
    position: randomPosition,
    comment: randomComment,
    deadline: '2025-12-31',
    processingTime: `2025-12-15 ${String(Math.floor(Math.random() * 12) + 8).padStart(2, '0')}:${String(Math.floor(Math.random() * 60)).padStart(2, '0')}:00`,
    completionStatus: randomCompletionStatus,
    creator: randomCreator
  });
}

export const queryFormSchema: FormSchemaGetter = () => QUERY_FORM_SCHEMA;

// 查询表单模式配置
const QUERY_FORM_SCHEMA = [
  {
    component: 'Select',
    fieldName: 'area',
    label: '片区',
    componentProps: {
      placeholder: '请选择片区',
      options: areaOptions,
    },
  },
  {
    component: 'Select',
    fieldName: 'station',
    label: '油站',
    componentProps: {
      placeholder: '请选择油站',
      options: stationOptions,
    },
  },
  {
    component: 'Select',
    fieldName: 'completionStatus',
    label: '完成状态',
    componentProps: {
      placeholder: '请选择完成状态',
      options: completionStatusOptions,
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'processingTimeRange',
    label: '处理时间',
    componentProps: {
      placeholder: '请选择处理时间',
      type: 'daterange',
      startPlaceholder: '开始时间',
      endPlaceholder: '结束时间',
    },
  },
  {
    component: 'Select',
    fieldName: 'position',
    label: '岗位',
    componentProps: {
      placeholder: '请选择岗位',
      options: positionOptions,
    },
  },
  {
    component: 'Select',
    fieldName: 'comment',
    label: '评论',
    componentProps: {
      placeholder: '请选择评论状态',
      options: commentOptions,
    },
  },
  {
    component: 'Select',
    fieldName: 'creator',
    label: '创建人',
    componentProps: {
      placeholder: '请选择创建人',
      options: creatorOptions,
    },
  },
  {
    component: 'Input',
    fieldName: 'executor',
    label: '执行人',
    componentProps: {
      placeholder: '请输入执行人',
    },
  },
  {
    component: 'Input',
    fieldName: 'taskName',
    label: '任务名称',
    componentProps: {
      placeholder: '请输入任务名称',
    },
  },
];
