/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2022-12-21 11:13:51
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2024-08-08 14:59:24
 * @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, type: string) => {

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



//获取二次分配计算

export type GetSecondaryDistriComputeParams = {
    computeDate: string; //核算年月
    unitCode: string; //核算单元代码
    current: number;
    pageSize: number;
}

export const getSecondaryDistriComputeTableData = (params: GetSecondaryDistriComputeParams) => {

    return request('/performance/second/getResult', {
        method: 'GET',
        params: { ...params }
    })

}

//保存编辑后结果

export const save = (data: any) => {
    return request('/performance/second/save', {
        method: 'POST',
        data
    })

}


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

    return request('/performance/second/getSubmitStatus', {
        method: 'GET',
        params: params
    })

}

//获取当前审核状态
export const getCurrentCheckStatusReq = (computeDate: string) => {
    return request('/performance/second/getAuditStatus', {
        method: 'GET',
        params: { computeDate }
    })

}

//获取当前核算单元审核状态
export const getCurrentUnitCheckStatusReq = (computeDate: string, unitCode: string) => {
    return request('/performance/second/getUnitAuditStatus', {
        method: 'GET',
        params: { computeDate, unitCode }
    })

}

//获取当前核算单元对应的报表Code
export const getCurrentUnitReportCodeReq = () => {
    return request('/performance/dict/getDictDataList?current=1&pageSize=100&typeCode=1', {
        method: 'GET',
    })

}



//提交请求

export type CommitRequestParamsType = {
    computeDate: string,
    unitCode: string,
    type: string
}
export const commitRequest = (data: CommitRequestParamsType) => {

    return request('/performance/second/submit', {
        method: 'POST',
        params: data
    })

}

//审核请求

export type CheckRequestParamsType = {
    computeDate: string,
    auditType: string,
    type: string //是否跳过提交状态验证 1跳过提交状态 不验证是否已提交 0或不传 验证是否已提交
}
export const checkRequest = (data: CheckRequestParamsType) => {

    return request('/performance/second/audit', {
        method: 'POST',
        params: data
    })

}

//只审核当前
export type CheckCurrentRequestParamsType = {
    computeDate: string,
    auditType: string,
    unitCode: string,
    type: string //是否跳过提交状态验证 1跳过提交状态 不验证是否已提交 0或不传 验证是否已提交
}
export const checkCurrentRequest = (data: CheckCurrentRequestParamsType) => {

    return request('/performance/second/auditUnit', {
        method: 'POST',
        params: data
    })

}


//自动计算
export const autoComputedReq = (data: { computeDate: string, unitCode: string }) => {

    return request('/performance/second/autoCompute', {
        method: 'POST',
        data: data
    })

}



//自动执行SQL
export const autoExecuteSql = (data: { sqlType: string, parameter: any }) => {

    return request('/performance/public/autoExecuteSql', {
        method: 'POST',
        data
    })

}
