import { request, type RequestOptions } from '@/utils/request';
const baseApi = '/api/sale_quotation/sale_quotation_component';
/** 获取报价配件列表 GET /api/sale_quotation_component */
export async function saleQuotationComponentList(params: API.SaleQuotationComponentParams, options?: RequestOptions) {
  return request<{
    items?: API.SaleQuotationComponentEntity[];
    meta?: {
      itemCount?: number;
      totalItems?: number;
      itemsPerPage?: number;
      totalPages?: number;
      currentPage?: number;
    };
  }>(baseApi, {
    method: 'GET',
    params: {
      // page has a default value: 1
      page: '1',
      // pageSize has a default value: 10
      pageSize: '10',

      ...params,
    },
    ...(options || {}),
  });
}

/** 新增报价配件 POST /api/sale_quotation_component */
export async function saleQuotationComponentCreate(body: API.SaleQuotationComponentDto, options?: RequestOptions) {
  return request<any>(baseApi, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || { successMsg: '创建成功' }),
  });
}

/** 获取报价配件信息 GET /api/sale_quotation_component/${param0} */
export async function saleQuotationComponentInfo(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.SaleQuotationComponentInfoParams,
  options?: RequestOptions,
) {
  const { id: param0, ...queryParams } = params;
  return request<API.SaleQuotationComponentEntity>(`${baseApi}/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 解除报价配件和附件关联 PUT /api/sale_quotation_component/unlink-attachments/${param0} */
export async function unlinkAttachments(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.SaleQuotationComponentUpdateParams,
  body: API.SaleQuotationComponentUpdateDto,
  options?: RequestOptions,
) {
  const { id: param0, ...queryParams } = params;
  return request<any>(`${baseApi}/unlink-attachments/${param0}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    params: { ...queryParams },
    data: body,
    ...options,
  });
}

/** 更新报价配件 PUT /api/sale_quotation_component/${param0} */
export async function saleQuotationComponentUpdate(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.SaleQuotationComponentUpdateParams,
  body: API.SaleQuotationComponentUpdateDto,
  options?: RequestOptions,
) {
  const { id: param0, ...queryParams } = params;
  return request<any>(`${baseApi}/${param0}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    params: { ...queryParams },
    data: body,
    ...(options || { successMsg: '更新成功' }),
  });
}

/** 删除报价配件 DELETE /api/sale_quotation_component/${param0} */
export async function saleQuotationComponentDelete(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.SaleQuotationComponentDeleteParams,
  options?: RequestOptions,
) {
  const { id: param0, ...queryParams } = params;
  return request<any>(`${baseApi}/${param0}`, {
    method: 'DELETE',
    params: { ...queryParams },
    ...(options || { successMsg: '删除成功' }),
  });
}
