import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PeriodManagementVO, PeriodManagementForm, PeriodManagementQuery } from '@/api/bfs/periodManagement/types';

/**
 * 查询会计期间管理列表
 * @param query
 * @returns {*}
 */

export const listPeriodManagement = (query?: PeriodManagementQuery): AxiosPromise<PeriodManagementVO[]> => {
  return request({
    url: '/bfs/periodManagement/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询会计期间管理详细
 * @param id
 */
export const getPeriodManagement = (id: string | number): AxiosPromise<PeriodManagementVO> => {
  return request({
    url: '/bfs/periodManagement/' + id,
    method: 'get'
  });
};

/**
 * 新增会计期间管理
 * @param data
 */
export const addPeriodManagement = (data: PeriodManagementForm) => {
  return request({
    url: '/bfs/periodManagement',
    method: 'post',
    data: data
  });
};

/**
 * 修改会计期间管理
 * @param data
 */
export const updatePeriodManagement = (data: PeriodManagementForm) => {
  return request({
    url: '/bfs/periodManagement',
    method: 'put',
    data: data
  });
};

/**
 * 删除会计期间管理
 * @param id
 */
export const delPeriodManagement = (id: string | number | Array<string | number>) => {
  return request({
    url: '/bfs/periodManagement/' + id,
    method: 'delete'
  });
};

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