import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BlindStructuresVO, BlindStructuresForm, BlindStructuresQuery } from '@/api/system/physical/blindStructures/types';

/**
 * 查询线下盲注等级主名列表
 * @param query
 * @returns {*}
 */

export const listBlindStructures = (query?: BlindStructuresQuery): AxiosPromise<BlindStructuresVO[]> => {
  return request({
    url: '/physical/blindStructures/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询线下盲注等级主名详细
 * @param id
 */
export const getBlindStructures = (id: string | number): AxiosPromise<BlindStructuresVO> => {
  return request({
    url: '/physical/blindStructures/' + id,
    method: 'get'
  });
};
export const addBlindStructures = (data: FormData) => {
  return request({
    url: '/physical/blindStructures',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
/**
 * 修改【盲注结构】
 * @param data FormData
 */
export const updateBlindStructures = (data: FormData) => {
  return request({
    url: '/physical/blindStructures/edit',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
/**
 * 删除线下盲注等级主名
 * @param id
 */
export const delBlindStructures = (id: string | number | Array<string | number>) => {
  return request({
    url: '/physical/blindStructures/' + id,
    method: 'delete'
  });
};

/**
 * 下载盲注级别导入模板
 */
export const downloadImportTemplate = async () => {
  const res = await request({
    url: '/physical/blindStructures/importPhysicalTemplate',
    method: 'POST',
    responseType: 'blob'
  });
  return res;
};

export const selectPhysicalBlingStructuresInfo = (): AxiosPromise<BlindStructuresVO> => {
  return request({
    url: '/physical/blindStructures/selectPhysicalBlingStructuresInfo',
    method: 'get'
  });
};
