import { defHttp } from '/@/utils/http/axios';
import {
  PageParams,
  CorporationListGetResultModel,
  UpdateCompanyParam,
  DeviceListItem,
  DeviceGetResultModel,
  ContractorModel,
} from './model';

import { Result, UploadFileParams } from '/#/axios';

enum Api {
  selectCompanyNum = '/service/manage_jp/company/list',
  listAllCompany = '/service/manage_jp/company/getListAll',
  selectCompanyByType = '/service/manage_jp/company/selectCompanyByType',
  uploadImage = '/service/manage_jp/file/uploadImg',
  uploadMusic = '/service/manage_jp/file/uploadMusic',
  updateCompany = '/service/manage_jp/company/insertOrUpdate',
  selectCompanyDevice = '/service/manage_jp/company/selectCompanyDevice',
  // unbindDevice = '/service/manage_jp/company/unbindDevice',
  unbindDevice = '/service/manage_jp/camera/unbind',
  contractorList = '/service/manage_jp/contractor/list',
}

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

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

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

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

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

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

export const ListCompanyDeviceApi = (params: DeviceListItem) =>
  defHttp.post<DeviceGetResultModel>({
    url: Api.selectCompanyDevice,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const unDeviceApi = (params: DeviceListItem) =>
  defHttp.post<DeviceGetResultModel>({
    url: Api.unbindDevice,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export function uploadLogoApi(
  params: UploadFileParams,
  // onUploadProgress: (progressEvent: ProgressEvent) => void,
) {
  return defHttp.uploadFile<Result>(
    {
      url: Api.uploadImage,
      // onUploadProgress,
    },
    params,
  );
}

export function uploadMusicApi(
  params: UploadFileParams,
  // onUploadProgress: (progressEvent: ProgressEvent) => void,
) {
  return defHttp.uploadFile<Result>(
    {
      url: Api.uploadMusic,
      // onUploadProgress,
    },
    params,
  );
}
//2.2.0 http://120.25.146.52:3090/project/325/interface/api/10100 承包商列表

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