import { request, type RequestOptions } from '@/utils/request';
const baseApi = '/api/sale_quotation/sale_quotation_template';
/** 获取报价模板列表 GET /api/sale_quotation_template */
export async function saleQuotationTemplateList(params: API.SaleQuotationTemplateParams, options?: RequestOptions) {
  return request<{
    items?: API.SaleQuotationTemplateEntity[];
    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_template */
export async function saleQuotationTemplateCreate(body: API.SaleQuotationTemplateDto, options?: RequestOptions) {
  return request<any>(baseApi, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || { successMsg: '创建成功' }),
  });
}

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

/** 解除报价模板和附件关联 PUT /api/sale_quotation_template/unlink-attachments/${param0} */
export async function unlinkAttachments(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.SaleQuotationTemplateUpdateParams,
  body: API.SaleQuotationTemplateUpdateDto,
  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_template/${param0} */
export async function saleQuotationTemplateUpdate(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.SaleQuotationTemplateUpdateParams,
  body: API.SaleQuotationTemplateUpdateDto,
  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_template/${param0} */
export async function saleQuotationTemplateDelete(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.SaleQuotationTemplateDeleteParams,
  options?: RequestOptions,
) {
  const { id: param0, ...queryParams } = params;
  return request<any>(`${baseApi}/${param0}`, {
    method: 'DELETE',
    params: { ...queryParams },
    ...(options || { successMsg: '删除成功' }),
  });
}
