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

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

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

interface OrdersPartialEntity
  extends Partial<Omit<OrdersEntity, 'ordersnumber'>> {
  ordersnumber?: string;
}

interface OrdersQueryParams extends OrdersPartialEntity, PageConfig {}

/**
 * 订单信息_列表
 */
export async function getOrdersListApi(params: OrdersQueryParams) {
  return requestClient.post<any>('/api/query/list?pagevalue=51', {
    ...params,
  });
}

/**
 * 订单信息_详情
 */
export async function getOrdersDetailApi(data: { ordersid: string }) {
  return requestClient.post<any>(
    '/api/query/view?pagevalue=52',
    {
      ...parseQueryValues(data),
    },
    { formatData: true }, // 格式化返回数据
  );
}

/**
 * 订单信息_新增
 */
export async function addOrdersApi(data: OrdersEntity) {
  return requestClient.post<any>('/api/add?pagevalue=53', { ...data });
}

/**
 * 客户信息_编辑
 */
export async function editOrdersApi(data: OrdersEntity) {
  return requestClient.post<any>('/api/up?pagevalue=54', { ...data });
}
