import { http } from "../utils/http";
import { loadEnv } from "@build/index";

const { VITE_PROXY_DOMAIN_REAL, VITE_PROXY_USER_REAL, VITE_WORKORDER_REAL } = loadEnv();
const userAPi = VITE_PROXY_DOMAIN_REAL;
const yewuApi = VITE_PROXY_USER_REAL + "/admin/";



const newApi = VITE_WORKORDER_REAL

interface postType extends Promise<any> {
  data?: object;
  code?: number;
  message?: string;
}

export const httpRelationDetail = (data?: object): postType => {
  return http.request("post", `${newApi}cxinv/invoiceItem/mergeItem`, { data });
};

export const httpInvoiceDetail = (data?: object): postType => {
  return http.request("post", `${yewuApi}InvoiceItem/getListByCode`, { data });
};

//销售订单发票票面
export const httpSaleInvoice = (data?: object): postType => {
  return http.request("post", `${yewuApi}orderticket`, { data });
};

//采购单回票发票票面信息
export const httpPurchaseInvoice = (data?: object): postType => {
  return http.request("post", `${newApi}/cxinv/invoice/Ticket`, { data });
};


export const httpDeleteInvoice = (data?: object): postType => {
  return http.request("post", `${newApi}cxinv/invoice/delete`, { data });
};

// 采购单列表
export const httpPurchaseOrders = (data?: object): postType => {
  return http.request("post", `${newApi}cxinv/InvoiceItem/cgdListByPayNo`, { data });
};

export const httpSaleOrders = (data?: object): postType => {
  return http.request("post", `${newApi}cxinv/InvoiceItem/qrdListByInvNo`, { data });
};


export const httpRelation = (data?: object): postType => {
  return http.request("post", `${newApi}cxinv/InvoiceItem/create`, { data });
};

export const httpOldRelation = (data?: object): postType => {
 return http.request("post", `${yewuApi}InvoiceItem/create`, { data });
}


export const httpUnRelation = (data?: object): postType => {
  return http.request("post", `${newApi}cxinv/InvoiceItem/delete`, { data });
};


export const httpOldUnRelation = (data?: object): postType => {
  return http.request("post", `${yewuApi}InvoiceItem/delete`, { data });
};
