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

// 报工数据统计类型定义
export interface WorkReportData {
  id: number;
  businessType: string; // 业务类型
  area: string; // 片区
  station: string; // 油站
  totalOrders: number; // 工单总数
  equipmentRepairCompleted: number; // 设备维修已完成数量
  equipmentRepairNotCompleted: number; // 设备维修未完成数量
  networkIssueCompleted: number; // 网络问题已完成数量
  networkIssueNotCompleted: number; // 网络问题未完成数量
  systemIssueCompleted: number; // 系统问题已完成数量
  systemIssueNotCompleted: number; // 系统问题未完成数量
}

// 报工数据统计表格配置
export const tableColumns: VxeGridProps['columns'] = [
  { title: '业务类型', field: 'businessType', minWidth: 120, align: 'center' },
  { title: '片区', field: 'area', minWidth: 120, align: 'center' },
  { title: '油站', field: 'station', minWidth: 150, align: 'center' },
  { title: '工单总数', field: 'totalOrders', minWidth: 100, align: 'center' },
  { 
    title: '设备维修', 
    minWidth: 240, 
    align: 'center', 
    children: [
      { title: '已完成数量', field: 'equipmentRepairCompleted', minWidth: 120, align: 'center' },
      { title: '未完成数量', field: 'equipmentRepairNotCompleted', minWidth: 120, align: 'center' },
    ]
  },
  { 
    title: '网络问题', 
    minWidth: 240, 
    align: 'center', 
    children: [
      { title: '已完成数量', field: 'networkIssueCompleted', minWidth: 120, align: 'center' },
      { title: '未完成数量', field: 'networkIssueNotCompleted', minWidth: 120, align: 'center' },
    ]
  },
  { 
    title: '系统问题', 
    minWidth: 240, 
    align: 'center', 
    children: [
      { title: '已完成数量', field: 'systemIssueCompleted', minWidth: 120, align: 'center' },
      { title: '未完成数量', field: 'systemIssueNotCompleted', minWidth: 120, align: 'center' },
    ]
  },
];

// 报工数据统计虚拟数据
export const WORK_REPORT_MOCK_DATA: WorkReportData[] = [
  { 
    id: 1, 
    businessType: '日常维护', 
    area: '默认片区', 
    station: '北京东加油站', 
    totalOrders: 125, 
    equipmentRepairCompleted: 45, 
    equipmentRepairNotCompleted: 5, 
    networkIssueCompleted: 35, 
    networkIssueNotCompleted: 10, 
    systemIssueCompleted: 25, 
    systemIssueNotCompleted: 5
  },
  { 
    id: 2, 
    businessType: '设备巡检', 
    area: '默认片区', 
    station: '北京西加油站', 
    totalOrders: 98, 
    equipmentRepairCompleted: 38, 
    equipmentRepairNotCompleted: 2, 
    networkIssueCompleted: 28, 
    networkIssueNotCompleted: 5, 
    systemIssueCompleted: 15, 
    systemIssueNotCompleted: 3
  },
  { 
    id: 3, 
    businessType: '故障维修', 
    area: '片区1', 
    station: '机场油站', 
    totalOrders: 156, 
    equipmentRepairCompleted: 65, 
    equipmentRepairNotCompleted: 8, 
    networkIssueCompleted: 42, 
    networkIssueNotCompleted: 12, 
    systemIssueCompleted: 22, 
    systemIssueNotCompleted: 7
  },
  { 
    id: 4, 
    businessType: '日常维护', 
    area: '片区2', 
    station: '北京南加油站', 
    totalOrders: 89, 
    equipmentRepairCompleted: 32, 
    equipmentRepairNotCompleted: 4, 
    networkIssueCompleted: 25, 
    networkIssueNotCompleted: 7, 
    systemIssueCompleted: 18, 
    systemIssueNotCompleted: 3
  },
  { 
    id: 5, 
    businessType: '设备巡检', 
    area: '片区3', 
    station: '北京北加油站', 
    totalOrders: 112, 
    equipmentRepairCompleted: 40, 
    equipmentRepairNotCompleted: 6, 
    networkIssueCompleted: 32, 
    networkIssueNotCompleted: 8, 
    systemIssueCompleted: 22, 
    systemIssueNotCompleted: 4
  },
  { 
    id: 6, 
    businessType: '故障维修', 
    area: '片区1', 
    station: '未来路加油站', 
    totalOrders: 134, 
    equipmentRepairCompleted: 52, 
    equipmentRepairNotCompleted: 7, 
    networkIssueCompleted: 38, 
    networkIssueNotCompleted: 9, 
    systemIssueCompleted: 25, 
    systemIssueNotCompleted: 3
  },
  { 
    id: 7, 
    businessType: '日常维护', 
    area: '片区2', 
    station: '龙飞虎加油站', 
    totalOrders: 95, 
    equipmentRepairCompleted: 35, 
    equipmentRepairNotCompleted: 5, 
    networkIssueCompleted: 28, 
    networkIssueNotCompleted: 6, 
    systemIssueCompleted: 19, 
    systemIssueNotCompleted: 2
  },
  { 
    id: 8, 
    businessType: '设备巡检', 
    area: '片区3', 
    station: '法站加油站', 
    totalOrders: 108, 
    equipmentRepairCompleted: 42, 
    equipmentRepairNotCompleted: 4, 
    networkIssueCompleted: 30, 
    networkIssueNotCompleted: 7, 
    systemIssueCompleted: 22, 
    systemIssueNotCompleted: 3
  },
];

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

// 查询表单模式配置
const QUERY_FORM_SCHEMA = [
  {
    component: 'Select',
    fieldName: 'station',
    label: '油站',
    componentProps: {
      placeholder: '请选择油站',
      options: [
        { label: '机场油站', value: '机场油站' },
        { label: '北京东加油站', value: '北京东加油站' },
        { label: '北京西加油站', value: '北京西加油站' },
        { label: '北京南加油站', value: '北京南加油站' },
        { label: '北京北加油站', value: '北京北加油站' },
        { label: '河北油站', value: '河北油站' },
        { label: '龙飞虎加油站', value: '龙飞虎加油站' },
        { label: '法站加油站', value: '法站加油站' },
      ],
    },
  },
  {
    component: 'Select',
    fieldName: 'area',
    label: '片区',
    componentProps: {
      placeholder: '请选择片区',
      options: [
        { label: '默认片区', value: '默认片区' },
        { label: '片区1', value: '片区1' },
        { label: '片区2', value: '片区2' },
        { label: '片区3', value: '片区3' },
      ],
    },
  },
];
