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

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

enum Api {
  selectCompanyNum = '/zfb-api/zfb/company/selectCompanyNum',
  listAllCompany = '/zfb-api/zfb/company/getListAll',
  selectCompanyByType = '/zfb-api/zfb/company/selectCompanyByType',
  uploadLogo = '/zfb-api/zfb/company/uploadLogo',
  saveCompany = '/zfb-api/zfb/company/back/save',
  updateCompany = '/zfb-api/zfb/company/updateCompany',
  selectCompanyDevice = '/zfb-api/zfb/company/selectCompanyDevice',
  unbindDevice = '/zfb-api/zfb/company/unbindDevice',
}

/**
 * @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 saveCompanyApi = (params: SaveCompanyParam) =>
  defHttp.post<Result>({
    url: Api.saveCompany,
    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.uploadLogo,
      // onUploadProgress,
    },
    params,
  );
}
// export function uploadMusicApi(
//   params: UploadFileParams,
//   // onUploadProgress: (progressEvent: ProgressEvent) => void,
// ) {
//   return defHttp.uploadFile<Result>(
//     {
//       url: Api.uploadMusic,
//       // onUploadProgress,
//     },
//     params,
//   );
// }
