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

// 接单部门数据统计类型定义
export interface OrderDepartData {
  id: number;
  department: string; // 部门
  totalOrders: number; // 接单总量
  completedOrders: number; // 已完成量
  uncompletedOrders: number; // 未完成量
  completionRate: string; // 完成率
  overdueOrders: number; // 逾期量
  overdueRate: string; // 逾期率
  averageProcessingTime: string; // 平均处理时长
  satisfaction: {
    totalEvaluations: number; // 评价总量
    satisfiedEvaluations: number; // 满意量
    satisfactionRate: string; // 满意率
  }; // 满意度
}

// 接单部门数据统计表格配置
export const tableColumns: VxeGridProps['columns'] = [
  { title: '部门', field: 'department', minWidth: 150, 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: '平均处理时长', field: 'averageProcessingTime', minWidth: 150, align: 'center' },
  { 
    title: '满意度', 
    minWidth: 300, 
    align: 'center', 
    children: [
      { title: '评价总量', field: 'satisfaction.totalEvaluations', minWidth: 100, align: 'center' },
      { title: '满意量', field: 'satisfaction.satisfiedEvaluations', minWidth: 100, align: 'center' },
      { title: '满意率', field: 'satisfaction.satisfactionRate', minWidth: 100, align: 'center' },
    ]
  },
];

// 接单部门数据统计虚拟数据
export const WORK_REPORT_MOCK_DATA: OrderDepartData[] = [
  { 
    id: 1, 
    department: '维修部', 
    totalOrders: 150, 
    completedOrders: 135, 
    uncompletedOrders: 15, 
    completionRate: '90%', 
    overdueOrders: 8, 
    overdueRate: '5.3%', 
    averageProcessingTime: '4.5小时', 
    satisfaction: {
      totalEvaluations: 120,
      satisfiedEvaluations: 110,
      satisfactionRate: '91.7%'
    }
  },
  { 
    id: 2, 
    department: '网络部', 
    totalOrders: 200, 
    completedOrders: 185, 
    uncompletedOrders: 15, 
    completionRate: '92.5%', 
    overdueOrders: 12, 
    overdueRate: '6%', 
    averageProcessingTime: '3.2小时', 
    satisfaction: {
      totalEvaluations: 170,
      satisfiedEvaluations: 160,
      satisfactionRate: '94.1%'
    }
  },
  { 
    id: 3, 
    department: '系统部', 
    totalOrders: 120, 
    completedOrders: 108, 
    uncompletedOrders: 12, 
    completionRate: '90%', 
    overdueOrders: 5, 
    overdueRate: '4.2%', 
    averageProcessingTime: '5.8小时', 
    satisfaction: {
      totalEvaluations: 95,
      satisfiedEvaluations: 88,
      satisfactionRate: '92.6%'
    }
  },
  { 
    id: 4, 
    department: '客服部', 
    totalOrders: 300, 
    completedOrders: 285, 
    uncompletedOrders: 15, 
    completionRate: '95%', 
    overdueOrders: 10, 
    overdueRate: '3.3%', 
    averageProcessingTime: '1.5小时', 
    satisfaction: {
      totalEvaluations: 270,
      satisfiedEvaluations: 255,
      satisfactionRate: '94.4%'
    }
  },
  { 
    id: 5, 
    department: '工程部', 
    totalOrders: 90, 
    completedOrders: 82, 
    uncompletedOrders: 8, 
    completionRate: '91.1%', 
    overdueOrders: 3, 
    overdueRate: '3.3%', 
    averageProcessingTime: '8.2小时', 
    satisfaction: {
      totalEvaluations: 75,
      satisfiedEvaluations: 70,
      satisfactionRate: '93.3%'
    }
  },
];

// 查询表单模式配置
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;
