/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2022-12-21 11:13:51
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-05-25 17:28:52
 * @FilePath: /BudgetManaSystem/src/pages/budgetMana/monthlyInfoCheck/service.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */




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




//获取树结构单元数据

export type getTreeDataRespType = {
    code: number,
    name: string,
    map:boolean,
    parentCode:string,
    unitType?:string,
    child: getTreeDataRespType[]
}

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

    return request<getTreeDataRespType[]>('/performance/secondSetting/getNonAssessmentUnitList', {
        method: 'GET',
        params: { computeDate }
    })
}



//获取非考核项目

export type GetNonCheckProjectParams = {
    computeDate: string; //核算年月
    unitCode: string; //核算单元代码
    name?: string; //人员信息 （工号、姓名）
    current: number;
    pageSize: number;
}

export const getNonCheckProjectTableData = (params: GetNonCheckProjectParams) => {

    return request('/performance/secondSetting/getNonAssessmentList', {
        method: 'GET',
        params: { ...params }
    })

}


//获取单元对应的可选非考核项目

export const getNonCheckProjectByUnitCode = (params:{unitCode:string}) => {

    return request('/performance/item/getUnitNonAssessmentList', {
        method: 'GET',
        params: { ...params }
    })

}



//添加非考核项目
export const addNonCheckProjectTableData = (data:{
    "computeDate":string, //核算年月
    "unitCode":string, //核算单元代码
    "deptCode":string, //科室代码
    "nonAssessmentCode":number, //非考核项目代码
    "targetValue":string, //工号
    "value":string, //值
    "description":string //说明
}) => {

    return request('/performance/secondSetting/addNonAssessment', {
        method: 'POST',
        data
    })

}

//添加非考核项目
export const editNonCheckProjectTableData = (data:{
    "id":number,
    "computeDate":string, //核算年月
    "unitCode":string, //核算单元代码
    "deptCode":string, //科室代码
    "nonAssessmentCode":number, //非考核项目代码
    "targetValue":string, //工号
    "value":string, //值
    "description":string //说明
}) => {

    return request('/performance/secondSetting/editNonAssessment', {
        method: 'POST',
        data
    })

}



//获取当前提交状态
export const getCurrentCommitStatusReq = (params:{
    computeDate:string,
    unitCode:string
}) => {

    return request('/performance/secondSetting/getNonAssessmentSubmitStatus', {
        method: 'GET',
        params: params
    })

}


//获取当前审核状态
export const getCurrentCheckStatus = (params:{
    computeDate:string,
}) => {

    return request('/performance/kpi/getStatus', {
        method: 'GET',
        params: params
    })

}




//删除
export const delRequest = (params:{
    computeDate:string,
    id:string,
    unitCode:string
}) => {

    return request('/performance/secondSetting/deleteNonAssessment', {
        method: 'POST',
        params: params
    })

}


//生成数据

export type GenerateDataRequestParamsType = {
    computeDate: string,
    unitCode: string,
}

export const generateDataRequest = (data: GenerateDataRequestParamsType) => {
 
    return request('/performance/secondSetting/generateEmployee', {
        method: 'POST',
        params:data
    })

}


//提交请求

export type CommitRequestParamsType = {
    computeDate:string,
    unitCode:string,
    type:string
}
export const commitRequest = (data:CommitRequestParamsType) => {
 
    return request('/performance/secondSetting/submitNonAssessment', {
        method: 'POST',
        params:data
    })

}


