/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2022-12-21 11:13:51
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-06-06 13:36:58
 * @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;
    child: getTreeDataRespType[]
}

export const getTreeData = () => {
     return getCheckUnitClassTableData()
}



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

export type pagesDataType = {

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


export type CheckUnitTableDataType = {
       
    id:number,
    hospId:number,
    code:string,
    unitName:string,
    classCode:string,
    unitType:string,
    unitTypeName:string,
    rate:string,
    description:string,
    specialUnit:number,
    unitLevel:string,
    unitLevelName:string

}

export const getCheckUnitTableDataByUnitClass = (params?:{
    current:number,
    pageSize:number,
    classCode:string,
    unitName:string
}) => {
    return request<{list:CheckUnitTableDataType[]}&pagesDataType>('/performance/unit/getUnitList', {
        method: 'GET',
        params: { ...params }
    })

}


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

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

}

export const editCheckUnit = (data:{id:number}&AddCheckUnitDataType) => {
    return request('/performance/unit/editUnitList', {
        method: 'POST',
        data
    })

}


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

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

}

