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

// 接单人数据统计类型定义
export interface OrderReceiveData {
  id: number;
  department: string; // 部门
  person: string; // 人员
  totalOrders: number; // 接单总量
  completedOrders: number; // 已完成量
  uncompletedOrders: number; // 未完成量
  completionRate: string; // 完成率
  overdueOrders: number; // 逾期量
  overdueRate: string; // 逾期率
  satisfaction: {
    totalEvaluations: number; // 评价总量
    satisfiedEvaluations: number; // 满意量
  }; // 满意度
}

// 接单人数据统计表格配置
export const tableColumns: VxeGridProps['columns'] = [
  { title: '部门', field: 'department', minWidth: 150, align: 'center' },
  { title: '人员', field: 'person', minWidth: 120, align: 'center' },
  { title: '接单总量', field: 'totalOrders', minWidth: 120, align: 'center' },
  { title: '已完成量', field: 'completedOrders', minWidth: 120, align: 'center' },
  { title: '未完成量', field: 'uncompletedOrders', minWidth: 120, align: 'center' },
  { title: '完成率', field: 'completionRate', minWidth: 120, align: 'center' },
  { title: '逾期量', field: 'overdueOrders', minWidth: 120, align: 'center' },
  { title: '逾期率', field: 'overdueRate', minWidth: 120, align: 'center' },
  { 
    title: '满意度', 
    minWidth: 240, 
    align: 'center', 
    children: [
      { title: '评价总量', field: 'satisfaction.totalEvaluations', minWidth: 120, align: 'center' },
      { title: '满意量', field: 'satisfaction.satisfiedEvaluations', minWidth: 120, align: 'center' },
    ]
  },
];

// 接单人数据统计虚拟数据
export const WORK_REPORT_MOCK_DATA: OrderReceiveData[] = [
  { 
    id: 1, 
    department: '维修部', 
    person: '张三', 
    totalOrders: 150, 
    completedOrders: 135, 
    uncompletedOrders: 15, 
    completionRate: '90%', 
    overdueOrders: 8, 
    overdueRate: '5.3%', 
    satisfaction: {
      totalEvaluations: 120,
      satisfiedEvaluations: 110
    }
  },
  { 
    id: 2, 
    department: '维修部', 
    person: '李四', 
    totalOrders: 120, 
    completedOrders: 110, 
    uncompletedOrders: 10, 
    completionRate: '91.7%', 
    overdueOrders: 5, 
    overdueRate: '4.2%', 
    satisfaction: {
      totalEvaluations: 100,
      satisfiedEvaluations: 95
    }
  },
  { 
    id: 3, 
    department: '网络部', 
    person: '王五', 
    totalOrders: 200, 
    completedOrders: 185, 
    uncompletedOrders: 15, 
    completionRate: '92.5%', 
    overdueOrders: 12, 
    overdueRate: '6%', 
    satisfaction: {
      totalEvaluations: 170,
      satisfiedEvaluations: 160
    }
  },
  { 
    id: 4, 
    department: '网络部', 
    person: '赵六', 
    totalOrders: 180, 
    completedOrders: 165, 
    uncompletedOrders: 15, 
    completionRate: '91.7%', 
    overdueOrders: 8, 
    overdueRate: '4.4%', 
    satisfaction: {
      totalEvaluations: 150,
      satisfiedEvaluations: 140
    }
  },
  { 
    id: 5, 
    department: '系统部', 
    person: '孙七', 
    totalOrders: 120, 
    completedOrders: 108, 
    uncompletedOrders: 12, 
    completionRate: '90%', 
    overdueOrders: 5, 
    overdueRate: '4.2%', 
    satisfaction: {
      totalEvaluations: 95,
      satisfiedEvaluations: 88
    }
  },
  { 
    id: 6, 
    department: '系统部', 
    person: '周八', 
    totalOrders: 100, 
    completedOrders: 92, 
    uncompletedOrders: 8, 
    completionRate: '92%', 
    overdueOrders: 4, 
    overdueRate: '4%', 
    satisfaction: {
      totalEvaluations: 85,
      satisfiedEvaluations: 80
    }
  },
  { 
    id: 7, 
    department: '客服部', 
    person: '吴九', 
    totalOrders: 300, 
    completedOrders: 285, 
    uncompletedOrders: 15, 
    completionRate: '95%', 
    overdueOrders: 10, 
    overdueRate: '3.3%', 
    satisfaction: {
      totalEvaluations: 270,
      satisfiedEvaluations: 255
    }
  },
  { 
    id: 8, 
    department: '工程部', 
    person: '郑十', 
    totalOrders: 90, 
    completedOrders: 82, 
    uncompletedOrders: 8, 
    completionRate: '91.1%', 
    overdueOrders: 3, 
    overdueRate: '3.3%', 
    satisfaction: {
      totalEvaluations: 75,
      satisfiedEvaluations: 70
    }
  },
];

// 查询表单模式配置
const QUERY_FORM_SCHEMA = [
  {
    component: 'Select',
    fieldName: 'orderType',
    label: '工单类型',
    componentProps: {
      placeholder: '请选择工单类型',
      options: [
        { label: '设备维修', value: 'equipmentRepair' },
        { label: '网络问题', value: 'networkIssue' },
        { label: '系统问题', value: 'systemIssue' },
        { label: '日常维护', value: 'dailyMaintenance' },
        { label: '设备巡检', value: 'equipmentInspection' },
        { label: '故障维修', value: 'faultRepair' },
      ],
    },
  },
];

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