import { request } from '@@/plugin-request/request';
import { stringify } from 'qs';

/**
 * 零售报备列表查询
 * @param param
 */
export async function queryReportHome(param: object) {
  return request(`/web/v1/report_homes?${stringify(param)}`);
}

/**
 * 报备成交
 * @param id
 */
export async function reportHomeSuccess(id: string) {
  return request(`/web/v1/report_homes/${id}/success`, {
    method: 'PATCH',
  });
}

/**
 * 报备放弃
 * @param id
 */
export async function reportHomeAbandon(id: string) {
  return request(`/web/v1/report_homes/${id}/abandon`, {
    method: 'PATCH',
  });
}

/**
 * 创建报备
 * @param params
 */
export async function createReportHome(params: object) {
  return request(`/web/v1/report_homes`, {
    method: 'POST',
    data: params,
  });
}

/**
 * 编辑报备
 * @param params
 */
export async function editReportHome(params: any) {
  return request(`/web/v1/report_homes/${params.record_id}`, {
    method: 'PUT',
    data: params,
  });
}

/**
 * 报备详情
 * @param id
 */
export async function queryReportHomeDetail(id: string) {
  return request(`/web/v1/report_homes/${id}`);
}

/**
 * 导出
 * @param params
 */
export async function queryExport(params: any) {
  console.log('params', params);
  return request(`/web/v1/reports/export?${stringify(params)}`, {
    method: 'GET',
    responseType: 'blob',
  });
}
