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

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

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

interface WorkerPartialEntity
  extends Partial<Omit<WorkerEntity, 'worker_gh' | 'worker_xm'>> {
  worker_xm?: string;
  worker_gh?: string;
}

interface WorkerQueryParams extends PageConfig, WorkerPartialEntity {
  [key: `${string}.value`]: boolean | number | string;
}

/**
 * 职员信息_列表
 */
export async function getWorkerListApi(params: WorkerQueryParams) {
  return requestClient.post<any>('/api/query/list?pagevalue=63', {
    ...params,
  });
}

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

/**
 * 职员信息_新增
 */
export async function addWorkerApi(data: WorkerEntity) {
  return requestClient.post<any>('/api/add?pagevalue=65', { ...data });
}

/**
 * 职员信息_编辑
 */
export async function editWorkerApi(data: WorkerEntity) {
  return requestClient.post<any>('/api/up?pagevalue=66', { ...data });
}
