import request from '@/config/axios'

// 每月薪资记录 VO
export interface SalaryMonthRecordVO {
  sRecordId: number // 主键
  title: string // 报表标题
  year: number // 年
  month: number // 月
  num: number // 计薪人数
  startTime: Date // 计薪开始日期
  endTime: Date // 计薪结束日期
  personalInsuranceAmount: number // 个人社保金额
  personalProvidentFundAmount: number // 个人公积金金额
  corporateInsuranceAmount: number // 公司社保金额
  corporateProvidentFundAmount: number // 公司社保金额
  expectedPaySalary: number // 预应发工资
  personalTax: number // 个人所得税
  realPaySalary: number // 预计实发工资
  optionHead: string // 薪资项表头
  examineRecordId: number // 审核记录id
  checkStatus: number // 状态  0待审核、1通过、2拒绝、3审核中 4:撤回 5 未提交  10 历史薪资 11核算完成
}

// 每月薪资记录 API
export const SalaryMonthRecordApi = {
  queryEmployeeHistorySalaryList: async (params: any) => {
    return await request.get({ url: `/hr/salary-month-record/queryEmployeeHistorySalaryList`, params })
  },
  // 查询每月薪资记录分页
  queryHistorySalaryList: async (params: any) => {
    return await request.get({ url: `/hr/salary-month-record/queryHistorySalaryList`, params })
  },

  getSalaryProjectReportList: async (params: any) => {
    return await request.get({ url: `/hr/salary-month-record/getSalaryProjectReportList`, params })
  },

  // 查询每月薪资记录详情
  getSalaryMonthRecord: async (id: number) => {
    return await request.get({ url: `/hr/salary-month-record/get?id=` + id })
  },

  // 新增每月薪资记录
  createSalaryMonthRecord: async (data: SalaryMonthRecordVO) => {
    return await request.post({ url: `/hr/salary-month-record/create`, data })
  },

  // 修改每月薪资记录
  updateSalaryMonthRecord: async (data: SalaryMonthRecordVO) => {
    return await request.put({ url: `/hr/salary-month-record/update`, data })
  },

  // 删除每月薪资记录
  deleteSalaryMonthRecord: async (id: number) => {
    return await request.delete({ url: `/hr/salary-month-record/delete?id=` + id })
  },

  // 完成每月薪资记录
  completeSalaryMonthRecord: async (id: number) => {
    return await request.delete({ url: `/hr/salary-month-record/complete?id=` + id })
  },

  // 删除每月薪资记录
  addNextMonthSalary: async (date: string,companyId: number) => {
    return await request.post({ url: `/hr/salary-month-record/addNextMonthSalary?date=` + date +'&companyId='+companyId})
  },

  // 导出每月薪资记录 Excel
  exportSalaryMonthRecord: async (params) => {
    return await request.download({ url: `/hr/salary-month-record/export-excel`, params })
  },
  // 查询最新的薪资记录
  queryLastSalaryMonthRecord: async (data: any) => {
    return await request.post({ url: `/hr/salary-month-record/queryLastSalaryMonthRecord`, data })
  },
  // 查询薪资列表
  querySalaryPageList: async (params: any) => {
    return await request.get({
      url: `/hr/salary-month-record/querySalaryPageList`,
      params
    })
  },
  // 查询计薪列表员工异动数量
  queryEmployeeChangeNum: async (data: any) => {
    return await request.post({
      url: `/hr/salary-month-record/queryEmployeeChangeNum`,
      data
    })
  },
  // 查询薪资/社保初始化配置是否存在
  hrSalaryConfigQueryInItConfig: async (data: any) => {
    return await request.post({
      url: `/hr/salary-config/queryInItConfig`,
      data
    })
  },
  // 查询薪资项表头
  querySalaryOptionHead: async (data: any) => {
    return await request.post({
      url: `/hr/salary-option/querySalaryOptionHead`,
      data
    })
  }
}
