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

enum Api {
  cameraList = '/service/manage/order/camera/list',
  cameraExport = '/service/manage/order/camera/export',
  cameraItem = '/service/manage/order/camera/item',
  incrementList = '/service/manage/order/increment/list',
  incrementExport = '/service/manage/order/increment/export',
  downList = '/service/manage/order/down/list',
  downExport = '/service/manage/order/down/export',
  pageInvoice = '/service/manage/invoice/pageInvoice',
  exportInvoice = '/service/manage/invoice/export',
  invoiceRegister = '/service/manage/invoice/invoiceRegister',
  getInvoiceRegisterDetail = '/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,
    fileName:'相机订单.xlsx',
    // 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,
    fileName:'权益订单.xlsx',
    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,
    fileName:'下载订单.xlsx',
    // 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,
    method:'POST',
    params,
    fileName:'发票记录.xlsx',
    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,
  );
 }