import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {
    ReceivePlanDetailVO,
    ReceivePlanDetailForm,
    ReceivePlanDetailQuery,
     ComputedPlan
} from '@/api/finance/receivePlanDetail/types';

/**
 * 查询回款计划详情列表
 * @param query
 * @returns {*}
 */

export const listReceivePlanDetail = (query?: ReceivePlanDetailQuery): AxiosPromise<{ records: ReceivePlanDetailVO[] }> => {
    return request({
        url: 'finance/receive/plan/list_page',
        method: 'post',
        data: query
    });
};

/**
 * 查询回款计划详情详细
 * @param id
 */
export const getReceivePlanDetail = (id: string | number): AxiosPromise<ReceivePlanDetailVO> => {
    return request({
        url: '/receivePlanDetail/receivePlanDetail/' + id,
        method: 'get'
    });
};

/**
 * 计算回款详情
 * @param id
 */
export const computedPlanDetail = (computedData: ComputedPlan): AxiosPromise<ComputedPlan[]> => {
    return request({
        url: '/finance/receive/plan/generate_plan',
        method: 'post',
        data: computedData
    });
};

/**
 * 新增回款计划详情
 * @param data
 */
export const addReceivePlanDetail = (data: ReceivePlanDetailForm) => {
    return request({
        url: '/finance/receive/plan/create_plan',
        method: 'post',
        data: data
    });
};

/**
 * 修改回款计划详情
 * @param data
 */
export const updateReceivePlanDetail = (data: ReceivePlanDetailForm) => {
    return request({
        url: '/receivePlanDetail/receivePlanDetail',
        method: 'put',
        data: data
    });
};

/**
 * 删除回款计划详情
 * @param id
 */
export const delReceivePlanDetail = (id: string | number | Array<string | number>) => {
    return request({
        url: '/receivePlanDetail/receivePlanDetail/' + id,
        method: 'delete'
    });
};
