import request from '@/config/axios'

// 薪资档案 VO
export interface SalaryArchivesVO {
  id: number // 主键
  changeReason: number // 调薪原因 1 入职核定 2 转正 3 晋升 4 调动 5 年中调薪 6 年度调薪 7 特别调薪 8 其他
  changeData: Date // 最近调整日期
  employeeId: number // 员工id
  changeType: number // 0 未定薪 1 已定薪 2 已调薪
  remarks: string // 备注
}

// 薪资档案 API
export const SalaryArchivesApi = {
  // 查询薪资档案分页
  getSalaryArchivesPage: async (params: any) => {
    return await request.get({ url: `/hr/salary-archives/page`, params })
  },

  // 查询薪资档案详情
  getSalaryArchives: async (id: number) => {
    return await request.get({ url: `/hr/salary-archives/get?id=` + id })
  },

  // 新增薪资档案
  createSalaryArchives: async (data: SalaryArchivesVO) => {
    return await request.post({ url: `/hr/salary-archives/create`, data })
  },

  // 修改薪资档案
  updateSalaryArchives: async (data: SalaryArchivesVO) => {
    return await request.put({ url: `/hr/salary-archives/update`, data })
  },

  // 删除薪资档案
  deleteSalaryArchives: async (id: number) => {
    return await request.delete({ url: `/hr/salary-archives/delete?id=` + id })
  },

  // 导出薪资档案 Excel
  exportSalaryArchives: async (params) => {
    return await request.download({ url: `/hr/salary-archives/export-excel`, params })
  },
  // 获取调薪模板
  queryChangeTemplateList: async (data: {}) => {
    return await request.post({ url: `/hr/salary-change-template/queryChangeTemplateList`, data })
  },
  // 查询调薪项的值
  queryChangeOptionByTemplateId: async (data: {}) => {
    return await request.post({
      url: `/hr/salary-archives/queryChangeOptionByTemplateId`,
      data,
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      }
    })
  },
  // 保存调薪
  setChangeSalaryRecord: async (data: {}) => {
    return await request.post({
      url: `/hr/salary-archives/setChangeSalaryRecord`,
      data,
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      }
    })
  },
  // 单个定薪
  setFixSalaryRecord: async (data: {}) => {
    return await request.post({
      url: `/hr/salary-archives/setFixSalaryRecord`,
      data,
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      }
    })
  },
  // 考勤导入模板
  downloadAdditionalDeductionTemp: async (params) => {
    return await request.download({
      url: `/hr/salary-month-record/downloadAdditionalDeductionTemp`,
      params
    })
  },
  // 保存核算薪资
  computeSalaryData: async (data: {}) => {
    return await request.post({
      url: `/hr/salary-month-record/computeSalaryData`,
      method: 'post',
      data,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },
  employeeById: async (id: number) => {
    return await request.get({ url: `/hr/employee/get?id=` + id })
  },
  // 所得税模板下载  /hr/salary-month-record/export-tax
  downloadSalaryMonthRecordTaxTemp: async (params) => {
    return await request.download({
      url: `/hr/salary-month-record/export-tax`,
      params
    })
  }
}
