/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2022-12-21 11:13:51
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-05-22 15:10:44
 * @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/getList', {
        method: 'GET',
    })
}



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

export type pagesDataType = {

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


export type CheckUnitDepMapTableDataType = {
       
    id:number,
    hospId:number,
    unitCode:string,
    deptCode:string,
    deptName:string,
    unitType:string,
    deptType:string,
    deptTypeName:string

}

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

}


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



export type AddCheckUnitDataType = {
    unitName:string,
    classCode:string,
    unitType:string,
    description:string,
    specialUnit:number,
    unitLevel:string
}

export const addCheckUnit = (data:AddCheckUnitDataType) => {
    return request('/performance/unit/addUnitList', {
        method: 'POST',
        data
    })

}


export type AddMapDepDataType = {
    unitCode:string,
    unitType:string,
    department:{
        deptCode:string,
        deptName:string,
        deptType:string,
        deptTypeName:string
    }[]
}

//添加对照科室
export const addMapDep = (data:AddMapDepDataType) => {

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

}



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

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

}

