import { request } from '@/utils/request'

// 组织管理
export const organizationApi = {
  // 个人信息
  getPersonalInfo: () => request.get('/organization/personal/info'),
  updatePersonalInfo: (data: any) => request.put('/organization/personal/info', data),
  updatePassword: (data: any) => request.put('/organization/personal/password', data),

  // 部门管理
  getDeptTree: () => request.get('/organization/dept/tree'),
  getDeptList: (params: any) => request.get('/organization/dept/list', params),
  addDept: (data: any) => request.post('/organization/dept', data),
  updateDept: (data: any) => request.put('/organization/dept', data),
  deleteDept: (id: number) => request.delete(`/organization/dept/${id}`),

  // 人员管理
  getStaffList: (params: any) => request.get('/organization/staff/list', params),
  addStaff: (data: any) => request.post('/organization/staff', data),
  updateStaff: (data: any) => request.put('/organization/staff', data),
  deleteStaff: (id: number) => request.delete(`/organization/staff/${id}`),
  updateStaffStatus: (id: number, status: number) => request.put(`/organization/staff/${id}/status`, { status }),

  // 角色管理
  getRoleList: (params: any) => request.get('/organization/role/list', params),
  addRole: (data: any) => request.post('/organization/role', data),
  updateRole: (data: any) => request.put('/organization/role', data),
  deleteRole: (id: number) => request.delete(`/organization/role/${id}`),
  getRoleStaff: (roleId: number, params: any) => request.get(`/organization/role/${roleId}/staff`, params),

  // 审批流程
  getApprovalList: (params: any) => request.get('/organization/approval/list', params),
  addApproval: (data: any) => request.post('/organization/approval', data),
  updateApproval: (data: any) => request.put('/organization/approval', data),
  deleteApproval: (id: number) => request.delete(`/organization/approval/${id}`),
  updateApprovalStatus: (id: number, status: number) => request.put(`/organization/approval/${id}/status`, { status }),

  // 集团关联企业
  getGroupEnterpriseList: (params: any) => request.get('/organization/group-enterprise/list', params),
  addGroupEnterprise: (data: any) => request.post('/organization/group-enterprise', data),
  deleteGroupEnterprise: (id: number) => request.delete(`/organization/group-enterprise/${id}`)
}
