/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2022-12-21 11:13:51
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-08-10 17:06:06
 * @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/getUnitList', {
        method: 'GET',
        params: { computeDate }
    })
}



//获取人员信息表格数据

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

export type PersonInfoType = {

    unitCode: number;
    empNo: string;
    empName: string;
    jobLevel: string;
    jobTitle: string;
    jobRate: string;
    seniority: string;
    userRate: number; // 人员系数
    seniorityRate: number; // 年资系数
    tagList: any[]; // 描述（数组类型，但忽略items字段）
    remark: string; // 备注

}

export type PersonInfoTableDataType = {
    current: number,
    list: PersonInfoType[],
    pageSize: number,
    totalCount: number,
    totalPage: number,
}

export const getPersonInfoTableData = (params: getPersonInfoTableDataParamsType) => {

    return request<PersonInfoTableDataType>('/performance/secondSetting/empList', {
        method: 'GET',
        params: { ...params }
    })

}


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

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

}

//获取可选人员列表

export const getTotalEmps = (params:{
    computeDate:string,
    unitCode:string
}) => {

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

}


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

    return request('/performance/secondSetting/deleteEmployee', {
        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/submitEmployee', {
        method: 'POST',
        params:data
    })

}

//保存添加的人员

export const saveEmpsRequest = (data:any[]) => {
 
    return request('/performance/secondSetting/addComputeEmployee', {
        method: 'POST',
        data:data
    })

}
