import { request, paramsSerializer } from '@/utils/request.js';

// person-files
export const personFilesListApi = (data) =>
  request({
    url: '/api/admin/user/archives/page',
    params: data,
  });
export const personFilesStatisticsApi = (data) =>
  request({
    url: '/api/admin/user/archives/sub_total',
    params: data,
  });
export const personFilesCodeApi = (data) =>
  request({
    url: '/api/admin/user/archives/create_code',
    data,
  });
export const personFilesEditApi = (data) =>
  request({
    url: '/api/admin/user/archives/edit',
    data,
  });
export const personFilesDestroyApi = (idList) =>
  request({
    url: '/api/admin/user/archives/cancel',
    params: { idList },
    paramsSerializer,
  });

export const personFilesExportApi = (data) =>
  request({
    url: '/api/admin/user/archives/export',
    params: data,
  });

// person-allocate
export const personAllocateListApi = (data) =>
  request({
    url: '/api/admin/user/archives/allocation/page',
    params: data,
  });
export const personAllocateStatisticsApi = (data) =>
  request({
    url: '/api/admin/user/archives/allocation/sub_total',
    params: data,
  });
export const personAllocateBatchDeployApi = ({ crmIdList, serviceUnitId }) =>
  request({
    url: '/api/admin/user/archives/allocation/auto_edit',
    data: { crmIdList, serviceUnitId },
  });
export const personAllocateRoleDetailApi = (crmNo) =>
  request({
    url: '/api/admin/user/archives/allocation/detail_by_crm_no',
    params: { crmNo },
  });
export const personAllocateDeployApi = (data) =>
  request({
    url: '/api/admin/user/archives/allocation/edit',
    data,
  });
export const personAllocateSubmitSopApi = (crmNo) =>
  request({
    url: '/api/admin/user/archives/allocation/publish',
    params: { crmNo },
  });
export const personAllocateCancelSubmitSopApi = (crmNo) =>
  request({
    url: '/api/admin/user/archives/allocation/un_publish',
    params: { crmNo },
  });
export const personAllocateFreeEngineerApi = (roleType, crmNo) =>
  request({
    url: '/api/admin/user/archives/allocation/free_engineer',
    params: { roleType, crmNo },
  });
export const personAllocateFreeCoordinatorApi = (serviceUnitId, crmNo) =>
  request({
    url: '/api/admin/user/archives/allocation/free_coordinator',
    params: { serviceUnitId, crmNo },
  });

// registration-query
export const registrationQueryListApi = (data) =>
  request({
    url: '/api/admin/device/in/out/source_page',
    params: data,
  });

//设备发货列表
export const deviceSendListApi = (data) =>
  request({
    url: '/api/admin/device/delivery/page',
    params: data,
  });

//修改设备发货单条
export const editDeviceSendApi = (data) =>
  request({
    url: '/api/admin/device/delivery/save',
    data,
    loading: true,
  });
export const deviceSendStatusUpdateApi = (params) =>
  request({
    url: '/api/admin/device/delivery/status/update',
    params,
    paramsSerializer,
  });
//批量返还
export const deviceSendReturn = (params) =>
  request({
    url: '/api/admin/device/delivery/can_return_info',
    params,
    paramsSerializer,
    loading: true,
  });
export const deviceSendExportApi = (data) =>
  request({
    url: '/api/admin/device/delivery/export',
    params: data,
    download: true,
  });
