import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FinItemDefVO, FinItemDefForm, FinItemDefQuery } from '@/api/bfs/finItemDef/types';

/**
 * 查询科目信息列表
 * @param query
 * @returns {*}
 */

export const listFinItemDef = (query?: FinItemDefQuery): AxiosPromise<FinItemDefVO[]> => {
  return request({
    url: '/bfs/finItemDef/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询科目信息详细
 * @param id
 */
export const getFinItemDef = (data) => {
  return request({
    url: '/bfs/finItemDef/getFinItemDef',
    method: 'post',
    data: data
  });
};

/**
 * 新增科目信息
 * @param data
 */
export const addFinItemDef = (data) => {
  return request({
    url: '/bfs/finItemDef/addItemDef',
    method: 'post',
    data: data
  });
};

/**
 * 修改科目信息
 * @param data
 */
export const updateFinItemDef = (data) => {
  return request({
    url: '/bfs/finItemDef/editItemDef',
    method: 'post',
    data: data
  });
};

/**
 * 删除科目信息
 * @param id
 */
export const delFinItemDef = (id: string | number | Array<string | number>) => {
  return request({
    url: '/bfs/finItemDef/delItemDef/' + id,
    method: 'post'
  });
};

export const getFinItemDict = () => {
  return request({
    url: '/bfs/finItemDef/getFinItemDict',
    method: 'get'
  });
};

export const getSubList = (finItemCode) => {
  const data = {
    finItemCode
  };
  return request({
    url: '/bfs/finItemDef/getSubList',
    method: 'post',
    data: data
  });
};

export const deleteSub = (data) => {
  return request({
    url: '/bfs/finItemDef/delSubItem',
    method: 'post',
    data: data
  });
};

export const addSub = (data) => {
  return request({
    url: '/bfs/finItemDef/addSubItem',
    method: 'post',
    data: data
  });
};

export const getFinItemList = () => {
  return request({
    url: '/bfs/finItemDef/getFinItem',
    method: 'post'
  });
};

export const changeStatus = (data, isUpdateItem) => {
  data.isUpdateItem = isUpdateItem;
  return request({
    url: '/bfs/finItemDef/changeStatus',
    method: 'post',
    data: data
  });
};

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