import { defHttp } from '/@/utils/http/axios';
import {
  PageParams,
  RentListGetResultModel,
  InvoiceListResul,
  addCameraParams,
  updateParams,
  getItemParams,
} from './model';
import { Result, UploadFileParams, FileStream } from '/#/axios';

enum Api {
  cameraList = '/manage/service/manage/order/camera/list',
  cameraExport = '/manage/service/manage/order/camera/export',
  cameraItem = '/manage/service/manage/order/camera/item',
  incrementList = '/manage/service/manage/order/increment/list',
  incrementExport = '/manage/service/manage/order/increment/export',
  downList = '/manage/service/manage/order/down/list',
  downExport = '/manage/service/manage/order/down/export',
  pageInvoice = '/manage/service/manage/invoice/pageInvoice',
  exportInvoice = '/manage/service/manage/invoice/export',
  invoiceRegister = '/manage/service/manage/invoice/invoiceRegister',
  getInvoiceRegisterDetail = '/manage/service/manage/invoice/getInvoiceRegisterDetail',
}

/**
 * @description: Get sample list value
 */

export const CameraList = (params: PageParams) =>
  defHttp.post<Result>({
    url: Api.cameraList,
    params: params,
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

/**
 * @description: Get sample list value
 */

export const CameraItem = (params: getItemParams) =>
  defHttp.get<Result>({
    url: Api.cameraItem,
    params,
    data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

/**
 * @description: 导出订单
 */

export const CameraExport = (params: PageParams) =>
  defHttp.downloadFile<FileStream>({
    url: Api.cameraExport,
    params: params,
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
    responseType: 'blob'
  });

/**
 * @description: Get sample list value
 */

export const IncrementExport = (params: PageParams) =>
  defHttp.downloadFile<FileStream>({
    url: Api.incrementExport,
    params: params,
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
    responseType: 'blob'
  });

export const IncrementList = (params: PageParams) =>
  defHttp.post<Result>({
    url: Api.incrementList,
    params: params,
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const DownExport = (params: PageParams) =>
  defHttp.downloadFile<FileStream>({
    url: Api.downExport,
    params: params,
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
    responseType: 'blob'
  });

export const DownList = (params: PageParams) =>
  defHttp.post<Result>({
    url: Api.downList,
    params: params,
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const InvoiceList = (params: PageParams) =>
  defHttp.post<InvoiceListResul>({
    url: Api.pageInvoice,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const InvoiceExport = (params: PageParams) =>
  defHttp.downloadFile<FileStream>({
    url: Api.exportInvoice,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
    responseType: 'blob'
  });

export const InvoiceDetail = (params: PageParams) =>
  defHttp.get<InvoiceListResul>({
    url: Api.getInvoiceRegisterDetail,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
  //上传文件
export function InvoiceRegister(
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) {
  return defHttp.uploadFile<Result>(
    {
      url: Api.invoiceRegister,
      onUploadProgress,
    },
    params,
  );
 }