/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-01-04 13:59:26
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2024-07-24 11:34:34
 * @FilePath: /BudgetManaSystem/src/pages/budgetMana/personnelSalaryBudget/service.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */





import { request } from '@@/plugin-request';




//获取薪酬预算表格数据

export type getDataRespType = {
    income:number,
    cost:number,
    rate:number,
    personalCost:number,
    detail:[
        unitType:string,
        unitTypeName:string,
        percent:string,
        cost:string,
        salary:string,
        subsidies:string,
        variableCompensation:string,
        staffRate:string,
        averageSalary:number
    ]

}

export const getData = (computeDate:string)=>{

    return request<getDataRespType>('/performance/bonus/getTotal', {
         method:'GET',
         params:{computeDate}
    })
}


//获取审核状态
export const getCurrentCheckStatus = (computeDate:string)=>{
    return request('/performance/bonus/getStatus', {
        method:'GET',
        params:{computeDate}
   })
}

//获取月度保留考核项目列表
export const getKpiRetainList = (computeDate:string)=>{
    return request('/performance/retain/kpiRetainList', {
        method:'GET',
        params:{computeDate}
   })
}

//审核
export const auditRequest = (data:{computeDate:string,auditType:string})=>{
    return request('/performance/bonus/audit', {
        method:'POST',
        params:data
    })
}

//保留金审核
export const checkRequest = (data:{computeDate:string,auditType:string,skipCheck:string})=>{
    return request('/performance/retain/auditUnitRetain', {
        method:'POST',
        params:data
    })
}

//生成
export const generate = (computeDate:string)=>{
    return request('/performance/bonus/generate', {
        method:'POST',
        params:{computeDate}
   })
}

//计算
export const caculate = (data:any)=>{
    return request('/performance/bonus/compute', {
        method:'POST',
        data
   })
}

//编辑
export const editAssessmentBonus = (data:any)=>{
    return request('/performance/bonus/editAssessmentBonus', {
        method:'POST',
        data
   })
}

//保存保留系数设定
export const saveKpiRetain = (data:any)=>{
    return request('/performance/retain/saveKpiRetain', {
        method:'POST',
        data
   })
}

//校验保留系数是否有调整
export const checkRetainStatusReq = (computeDate:string)=>{
    return request('/performance/bonus/checkRetainStatus', {
        method:'GET',
        params:{computeDate}
    })
}

//获取tab列表
export const getUnitTypes = ()=>{
    return request('/performance/dict/getDictDataList?current=1&pageSize=500&typeCode=1', {
        method:'GET',
   })
}

//获取月度职类保留奖金
export const getUnitRetainListReq = (computeDate:string,unitType:string)=>{
    return request('/performance/retain/getUnitRetainList', {
        method:'GET',
        params:{computeDate,unitType}
   })
}

//获取可分配金额
export const getKpiRemainRetainList = (unitType:string,retainCode:string)=>{
    return request('/performance/retain/kpiRemainRetainList', {
        method:'GET',
        params:{retainCode:retainCode == 'totalBonus'?null:retainCode,unitType}
   })
}


//保存月度职类保留奖金
export const saveUnitRetainReq = (data:any)=>{
    return request('/performance/retain/saveUnitRetain', {
        method:'POST',
        data
   })
}


//获取中台参数
export const getAllParameter = ()=>{
    return request('/performance/parameter/getList?current=1&pageSize=500', {
        method:'GET',
   })
}


//复制上一个月
export const copyReq = (computeDate:string)=>{
    return request('/performance/retain/copyLastKpiRetain', {
        method:'POST',
        params:{computeDate}
   })
}


