import request from '@/config/axios'
import { DepartmentListResponse, DepartmentUserParams, DepartmentUserResponse } from './types'

export const getDepartmentApi = () => {
  return request.get<DepartmentListResponse>({ url: '/department/list' })
}

export const getUserByIdApi = (params: DepartmentUserParams) => {
  return request.get<DepartmentUserResponse>({ url: '/department/users', params })
}

export const deleteUserByIdApi = (ids: string[] | number[]) => {
  return request.post({ url: '/department/user/delete', data: { ids } })
}

export const saveUserApi = (data: any) => {
  return request.post({ url: '/department/user/save', data })
}

export const saveDepartmentApi = (data: any) => {
  return request.post({ url: '/department/save', data })
}

export const deleteApi = (jPid: string, jName: string) => {
  return request.post({ url: '/job/sysJob/delete', data: { jPid, jName } })
}

export const getDepartmentTableApi = (params: any) => {
  return request.get({ url: '/krm-job/api/job/RepJobQueryPage', params })
}

export const runDataApi = (jobId: string, jName: string) => {
  return request.post({ url: '/job/sysJob/run', data: { jobId, jName } })
}

export const runCDataApi = (jobId: string, jName: string) => {
  return request.post({ url: '/job/sysJob/runC', data: { jobId, jName } })
}

/** 导入 */
export const importExcelApiUrl = '/krm-job/fileup/job/RepJobImport'

/** 导出 */
export const exportExcelApi = (params: any) => {
  return request.doExport({ url: '/export/spi/krmJob/filedown/job/RepJobExport', params })
}
