import { defHttp } from '/@/utils/http/axios';
import { Result, FileStream } from '/#/axios';
import { useI18n } from '/@/hooks/web/useI18n';
import { detailResult } from './model';
const { t } = useI18n();

enum Api {
  saleOrderList = '/service/sale/salePersonnel/saleOrderList',//工单列表
  orderReceiving = '/service/sale/salePersonnel/orderReceiving',//工单接单
  getByRoleType = '/service/sale/sysUser/getByRoleType',//根据角色类型获取用户列表
  updateRemark = '/service/sale/salePersonnel/updateRemark',//单修改备注
  recording = '/service/sale/salePersonnel/recording',//系统录单
  allList = '/service/sale/laborCost/allList',//人工费用全部列表
  getPriceList = '/service/sale/salePersonnel/getPriceList',//根据工单号获取报价单
  addOrUpdatePriceList = '/service/sale/salePersonnel/addOrUpdatePriceList',//添加或修改报价单
  confirmRepair = '/service/sale/salePersonnel/confirmRepair',//确认维修
  payRegister = '/service/sale/salePersonnel/payRegister',//付款登记
  sendRegister = '/service/sale/salePersonnel/sendRegister',//发货登记
  supplyOrderList = '/service/sale/supplyPersonnel/supplyOrderList',//维修备件管理 供应链 列表
  partRecovery = '/service/sale/supplyPersonnel/partRecovery',//备件回收
  partOut = '/service/sale/supplyPersonnel/partOut',//备件出库
  repairOrderList = '/service/sale/repairPersonnel/repairOrderList',//工单列表
  detail = '/service/sale/repairInfo/details',//工单详情
  process = '/service/sale/repairInfo/process',//工单流程
  partList = '/service/sale/part/list',//备件列表
  faultAllList = '/service/sale/fault/allList',//故障列表
  checkRegisterInfo = '/service/sale/repairPersonnel/checkRegisterInfo',//维修登记，维修完成回显详情
  checkRegister = '/service/sale/repairPersonnel/checkRegister',//维修登记
  partAllList = '/service/sale/part/allList',//全部备件列表没分页
  partAddOrUpdate = '/service/sale/part/addOrUpdate',//新增设备，修改设备，修改状态
  partInStock = '/service/sale/part/inStock',//添加库存，入库
  repairAddPart = '/service/sale/repairPersonnel/repairAddPart',//维修中添加备件
  repairOver = '/service/sale/repairPersonnel/repairOver',//维修完成
  partInStockLog = '/service/sale/part/inStockLog',//添加库存，入库 日志列表
  partInfoList = '/service/sale/supplyPersonnel/partInfo',//备件入库
  repairTesterList = '/service/sale/repairTest/repairTesterList',//测试列表
  testPassOrFail = '/service/sale/repairTest/testPassOrFail',//测试列表
  queryList = '/service/sale/repairInfo/list',//工单查询
  export = '/service/sale/repairPay/export',//导出列表
  repairPayList = '/service/sale/repairPay/list',//售后列表
  exportExcel = '/service/sale/repairInfo/exportExcel'
}

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

 interface logDataResule {
  lastDownNum: number;
  lastHighNum: number;
  lastMajorNum: number;
}
 export const saleOrderList = (params) =>
 defHttp.post<logDataResule>({
   url: Api.saleOrderList,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const detail = (params) =>
 defHttp.get<detailResult>({
   url: Api.detail,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

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

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

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

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

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

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

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

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


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

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

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


 export const sendRegister = (params) =>
 defHttp.post<Result>({
   url: Api.sendRegister,
   params: params,
   // data: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });
 export const supplyOrderList = (params) =>
 defHttp.post<Result>({
   url: Api.supplyOrderList,
   params: params,
   // data: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });
 
 export const partInfo = (params) =>
 defHttp.get<Result>({
   url: Api.partInfoList,
   params: params,
   // data: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });
 
 export const partRecovery = (params) =>
 defHttp.post<Result>({
   url: Api.partRecovery,
   params: params,
   // data: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

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

 export const partList = (params) =>
 defHttp.post<detailResult>({
   url: Api.partList,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });
 
 export const partAllList = (params) =>
 defHttp.post<detailResult>({
   url: Api.partAllList,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const checkRegister = (params) =>
 defHttp.post<detailResult>({
   url: Api.checkRegister,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const checkRegisterInfo = (params) =>
 defHttp.get<detailResult>({
   url: Api.checkRegisterInfo,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const faultAllList = (params) =>
 defHttp.get<detailResult>({
   url: Api.faultAllList,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const partAddOrUpdate = (params) =>
 defHttp.post<detailResult>({
   url: Api.partAddOrUpdate,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 }); 

 export const partInStock = (params) =>
 defHttp.post<detailResult>({
   url: Api.partInStock,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const repairOver = (params) =>
 defHttp.post<detailResult>({
   url: Api.repairOver,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const partInStockLog = (params) =>
 defHttp.post<detailResult>({
   url: Api.partInStockLog,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const repairAddPart = (params) =>
 defHttp.post<detailResult>({
   url: Api.repairAddPart,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });

 export const testPassOrFail = (params) =>
 defHttp.post<detailResult>({
   url: Api.testPassOrFail,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });
 
 export const repairTesterList = (params) =>
 defHttp.post<detailResult>({
   url: Api.repairTesterList,
   params: params,
   headers: {
     // @ts-ignore
     ignoreCancelToken: true,
   },
 });
 export const DownExport = (params) =>
  defHttp.downloadFile<FileStream>({
    url: Api.export,// + `?lang=${params.lang}`,
    params: params,
    fileName:'售后订单列表.xlsx',
    // data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
    responseType: 'blob'
  });

  export const detailDownExport = (params) =>{
    return  defHttp.downloadFile<FileStream>({
      url: Api.exportExcel+`?repairId=${params.repairId}&type=${params.type}`,
      params: params,
      fileName:params.name+'.pdf',
      // data: params,
      headers: {
        // @ts-ignore
        ignoreCancelToken: true,
      },
      responseType: 'blob'
    });
  }
