/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2022-12-21 11:13:51
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-09-20 14:52:57
 * @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';
import { getCheckUnitClassTableData } from '../checkUnitClassMana/service';




//获取树结构单元数据

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

export const getTreeData = () => {
    return request('/performance/unit/getEmpUnitList', {
        method: 'GET',
    })
}



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

export type pagesDataType = {

    current: number,
    pageSize: number,
    totalCount: number,
    totalPage: number,
}


export type CheckUnitEmpMapTableDataType = {[key:string]:any}

export const getCheckUnitEmpMapTableDataByUnitClass = (params?:{
    current:number,
    pageSize:number,
    unitCode:string,
    empName:string
}) => {
    return request<{list:CheckUnitEmpMapTableDataType[]}&pagesDataType>('/performance/unit/getUnitEmpMap', {
        method: 'GET',
        params: { ...params }
    })

}


//获取对照列表
export const getMapEmpList = () => {
    return request('/performance/unit/getEmployee', {
        method: 'GET',
    })
}




export type AddMapEmpDataType = {
    unitCode:string,
    unitType:string,
    employee:any[]
}

//添加对照人员
export const addMapEmp = (data:AddMapEmpDataType) => {

    return request('/performance/unit/addUnitEmpMap', {
        method: 'POST',
        data
    })

}



//删除
export const delTableData = ( id:number) => {

    return request('/performance/unit/deleteUnitEmpMap', {
        method: 'POST',
        params: {id}
    })

}

//更新人员信息

export const updateEmpInfoReq = () => {

    return request('/performance/unit/updateEmployee', {
        method: 'POST',
    })
}

//移动人员
export const moveEmpToUnit = (data:any) => {

    return request('/performance/unit/addEmployeeUnitMap', {
        method: 'POST',
        data
    })
}

//获取人员单元对照数据列表、
export const getEmpUnitMap = (params:{
    current:number,
    pageSize:number,
    unitCode:string,
    empName:string
}) => {

    return request('/performance/unit/getEmployeeUnitMap', {
        method: 'GET',
        params
    })
}



