/**
 * 岗位列表模拟数据
 */

import type { Position } from '../admin/position'
import type { PageResponse } from '../config'

// 扩展 Position 接口以包含页面所需字段
interface ExtendedPosition extends Position {
  requiredCourses?: number
  optionalCourses?: number
  skills?: string[]
  avgProgress?: number
  avgScore?: number
  updateTime?: string
}

const positions: ExtendedPosition[] = [
  {
    id: 1,
    name: '总经理',
    code: 'GM',
    parentId: null,
    memberCount: 1,
    description: '公司最高管理者',
    status: 'active',
    createTime: '2024-01-01 10:00:00',
    requiredCourses: 20,
    optionalCourses: 15,
    skills: ['战略规划', '团队管理', '决策能力', '沟通协调'],
    avgProgress: 95,
    avgScore: 92.5,
    updateTime: '2024-03-20 14:30:00'
  },
  {
    id: 2,
    name: '美容部',
    code: 'BEAUTY',
    parentId: 1,
    parentName: '总经理',
    memberCount: 25,
    description: '负责美容项目和客户服务',
    status: 'active',
    createTime: '2024-01-05 14:30:00',
    requiredCourses: 15,
    optionalCourses: 10,
    skills: ['美容咨询', '项目管理', '客户服务', '团队管理'],
    avgProgress: 82,
    avgScore: 86.7,
    updateTime: '2024-03-18 16:20:00'
  },
  {
    id: 3,
    name: '医美部',
    code: 'MEDICAL',
    parentId: 1,
    parentName: '总经理',
    memberCount: 30,
    description: '负责轻医美项目和医美技术支持',
    status: 'active',
    createTime: '2024-01-05 14:35:00',
    requiredCourses: 18,
    optionalCourses: 20,
    skills: ['医美技术', '项目管理', '安全管理', '团队协作'],
    avgProgress: 88,
    avgScore: 90.2,
    updateTime: '2024-03-19 10:15:00'
  },
  {
    id: 4,
    name: '美容顾问',
    code: 'BEAUTY_CONSULTANT',
    parentId: 2,
    parentName: '美容部',
    memberCount: 3,
    description: '为客户提供专业美容咨询和方案建议',
    status: 'active',
    createTime: '2024-01-10 09:00:00',
    requiredCourses: 15,
    optionalCourses: 10,
    skills: ['美容知识', '咨询技巧', '客户管理', '沟通技巧'],
    avgProgress: 85,
    avgScore: 88.3,
    updateTime: '2024-03-10 11:45:00'
  },
  {
    id: 5,
    name: '美容师',
    code: 'BEAUTICIAN',
    parentId: 2,
    parentName: '美容部',
    memberCount: 20,
    description: '为客户提供专业美容护理和治疗服务',
    status: 'active',
    createTime: '2024-01-10 09:10:00',
    requiredCourses: 12,
    optionalCourses: 8,
    skills: ['美容技能', '操作技术', '产品知识', '客户服务'],
    avgProgress: 78,
    avgScore: 82.5,
    updateTime: '2024-03-18 15:30:00'
  },
  {
    id: 6,
    name: '医美医生',
    code: 'DOCTOR',
    parentId: 3,
    parentName: '医美部',
    memberCount: 10,
    description: '负责医美项目的医学指导和技术支持',
    status: 'active',
    createTime: '2024-01-10 09:20:00',
    requiredCourses: 10,
    optionalCourses: 15,
    skills: ['医学知识', '美容技术', '安全操作', '效果评估'],
    avgProgress: 85,
    avgScore: 87.6,
    updateTime: '2024-03-20 09:00:00'
  },
  {
    id: 7,
    name: '美容技师',
    code: 'TECHNICIAN',
    parentId: 3,
    parentName: '医美部',
    memberCount: 12,
    description: '负责美容设备操作和技术支持',
    status: 'active',
    createTime: '2024-01-10 09:25:00',
    requiredCourses: 12,
    optionalCourses: 18,
    skills: ['设备操作', '技术支持', '安全管理', '效果监控'],
    avgProgress: 90,
    avgScore: 91.3,
    updateTime: '2024-03-19 17:20:00'
  },
  {
    id: 8,
    name: '客户服务专员',
    code: 'SERVICE',
    parentId: 3,
    parentName: '医美部',
    memberCount: 8,
    description: '负责客户服务和售后支持',
    status: 'active',
    createTime: '2024-01-10 09:30:00',
    requiredCourses: 8,
    optionalCourses: 10,
    skills: ['客户服务', '售后支持', '问题处理', '沟通技巧'],
    avgProgress: 82,
    avgScore: 85.9,
    updateTime: '2024-03-21 13:40:00'
  }
]

// 模拟分页和搜索
const mockData = (params?: any): PageResponse<Position> => {
  const { page = 1, pageSize = 10, keyword = '' } = params || {}
  
  // 搜索过滤
  let filteredList = positions
  if (keyword) {
    filteredList = positions.filter(item => 
      item.name.includes(keyword) || 
      item.code.includes(keyword) ||
      item.description.includes(keyword)
    )
  }
  
  // 分页
  const start = (page - 1) * pageSize
  const end = start + pageSize
  const list = filteredList.slice(start, end)
  
  return {
    list,
    total: filteredList.length,
    page,
    pageSize
  }
}

export default mockData
