import type { PageConfig, SubsidyApplicationsEntity } from '@vben/types';

import { parseQueryValues } from '@vben/utils';

import { requestClient } from '#/api/request';

interface SubsidyApplicationsPartialEntity
  extends Partial<
    Omit<
      SubsidyApplicationsEntity,
      'subsidyapplicationsapplydate' | 'subsidyapplicationsmerchantid'
    >
  > {
  subsidyapplicationsapplydate?: string;
  subsidyapplicationsmerchantid?: string;
}

interface SubsidyApplicationsQueryParams
  extends PageConfig,
    SubsidyApplicationsPartialEntity {}

/**
 * 补贴申请_列表
 */
export async function getSubsidyApplicationsListApi(
  params: SubsidyApplicationsQueryParams,
) {
  return requestClient.post<any>('/api/query/list?pagevalue=46', {
    ...params,
  });
}

/**
 * 补贴申请_详情
 */
export async function getSubsidyApplicationsDetailApi(data: {
  subsidyapplicationsid: string;
}) {
  return requestClient.post<any>(
    '/api/query/view?pagevalue=47',
    {
      ...parseQueryValues(data),
    },
    { formatData: true }, // 格式化返回数据
  );
}

/**
 * 补贴申请_新增
 */
export async function addSubsidyApplicationsApi(
  data: SubsidyApplicationsEntity,
) {
  return requestClient.post<any>('/api/add?pagevalue=48', { ...data });
}

/**
 * 补贴申请_编辑
 */
export async function editSubsidyApplicationsApi(
  data: SubsidyApplicationsEntity,
) {
  return requestClient.post<any>('/api/up?pagevalue=49', { ...data });
}
