import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SchemeVO, SchemeForm, SchemeQuery } from '@/api/system/business/scheme/types';

/**
 * 查询创建方案：用于定义排期生成规则模板列表
 * @param query
 * @returns {*}
 */

export const listScheme = (query?: SchemeQuery): AxiosPromise<SchemeVO[]> => {
  return request({
    url: '/business/scheme/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询创建方案：用于定义排期生成规则模板详细
 * @param id
 */
export const getScheme = (id: string | number): AxiosPromise<SchemeVO> => {
  return request({
    url: '/business/scheme/' + id,
    method: 'get'
  });
};

/**
 * 新增创建方案：用于定义排期生成规则模板
 * @param data
 */
export const addScheme = (data: SchemeForm) => {
  return request({
    url: '/business/scheme',
    method: 'post',
    data: data
  });
};

/**
 * 修改创建方案：用于定义排期生成规则模板
 * @param data
 */
export const updateScheme = (data: SchemeForm) => {
  return request({
    url: '/business/scheme',
    method: 'put',
    data: data
  });
};

/**
 * 删除创建方案：用于定义排期生成规则模板
 * @param id
 */
export const delScheme = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/scheme/' + id,
    method: 'delete'
  });
};

/**
 * 查询所有模版
 */
export const selectAllCreationSchemesAllList = (): AxiosPromise<SchemeVO> => {
  return request({
    url: '/business/scheme/selectAllCreationSchemesAllList',
    method: 'get'
  });
};
