import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CertificateTypeDefVO, CertificateTypeDefForm, CertificateTypeDefQuery } from '@/api/bfs/fiCertificateType/certificateType';
import { CostTypeDefForm } from '@/api/bfs/fiCertificateType/costType';

/**
 * 查询凭证类型定义列表
 * @param query
 * @returns {*}
 */

export const listCertificateTypeDef = (query?: CertificateTypeDefQuery): AxiosPromise<CertificateTypeDefVO[]> => {
  return request({
    url: '/bfs/certificateTypeDef/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询凭证类型定义详细
 * @param id
 */
export const getCertificateTypeDef = (id: string | number): AxiosPromise<CertificateTypeDefVO> => {
  return request({
    url: '/bfs/certificateTypeDef/' + id,
    method: 'get'
  });
};

/**
 * 新增凭证类型定义
 * @param data
 */
export const addCertificateTypeDef = (data: CertificateTypeDefForm) => {
  return request({
    url: '/bfs/certificateTypeDef',
    method: 'post',
    data: data
  });
};

/**
 * 修改凭证类型定义
 * @param data
 */
export const updateCertificateTypeDef = (data: CertificateTypeDefForm) => {
  return request({
    url: '/bfs/certificateTypeDef',
    method: 'put',
    data: data
  });
};

/**
 * 删除凭证类型定义
 * @param id
 */
export const delCertificateTypeDef = (id: string | number | Array<string | number>) => {
  return request({
    url: '/bfs/certificateTypeDef/' + id,
    method: 'delete'
  });
};

/**
 * 查询费用类型
 */
export const getCostTypeDefList = (certificateId: string) => {
  const data = {
    certificateId
  };
  return request({
    url: '/bfs/costTypeDef/getListByCertificateId',
    method: 'post',
    data: data
  });
};
export const getCostTypeDef = (id: string | number) => {
  const data = {
    id
  };
  return request({
    url: '/bfs/costTypeDef/getCostTypeDef',
    method: 'post',
    data: data
  });
};

export const changeCostTypeStatus = (id: string | number, state: string ) => {
  const data = {
    id,
    state
  };
  return request({
    url: '/bfs/costTypeDef/changeCostTypeStatus',
    method: 'post',
    data: data
  });
};

export const updateCostTypeDef = (data: CostTypeDefForm) => {
  return request({
    url: '/bfs/costTypeDef/updateCostTypeDef',
    method: 'post',
    data: data
  });
};

export const addCostTypeDef = (data: CostTypeDefForm) => {
  return request({
    url: '/bfs/costTypeDef/addCostTypeDef',
    method: 'post',
    data: data
  });
};
