import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RevenueHeaderVO, RevenueHeaderForm, RevenueHeaderQuery } from '@/api/order/revenueHeader/types';

/**
 * 查询收入单主列表
 * @param query
 * @returns {*}
 */

export const listRevenueHeader = (query?: RevenueHeaderQuery): AxiosPromise<RevenueHeaderVO[]> => {
  return request({
    url: '/order/revenueHeader/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询收入单主详细
 * @param id
 */
export const getRevenueHeader = (id: string | number): AxiosPromise<RevenueHeaderVO> => {
  return request({
    url: '/order/revenueHeader/' + id,
    method: 'get'
  });
};

/**
 * 新增收入单主
 * @param data
 */
export const addRevenueHeader = (data: RevenueHeaderForm) => {
  return request({
    url: '/order/revenueHeader',
    method: 'post',
    data: data
  });
};

/**
 * 修改收入单主
 * @param data
 */
export const updateRevenueHeader = (data: RevenueHeaderForm) => {
  return request({
    url: '/order/revenueHeader',
    method: 'put',
    data: data
  });
};

/**
 * 删除收入单主
 * @param id
 */
export const delRevenueHeader = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/revenueHeader/' + id,
    method: 'delete'
  });
};

export function changeStatus(id: string | number, status: string) {
  const data = {
    id,
    status
  };
  return request({
    url: '/order/revenueHeader/changeStatus',
    method: 'put',
    data: data
  });
}
