import request, { downloadExcelRequest } from '../utils/request';
import { Result, ResultList, _Pager_Params } from './types';
// 医护执业
export interface DoctorJobFields {
  remark: string;
  userUuid: string;
  orgCode: string;
  userFlow: string;
  medStaId: string;
  transInDate: string;
  transOutDate: string;
  reEmployPerson: string;
  eStabMent: string;
  officePhone: string;
  preScription: string;
  onJobCode: string;
  staDeptCode: string;
  deptName: string;
  deptCode: string;
  deptUuid: string;
  deleteTag: string;
  orgSign: string;
}
// 医护
export interface DoctorFields {
  searchValue: string;
  createBy: string;
  createTime: string;
  updateBy: string;
  updateTime: string;
  remark: string;
  params: Record<string, any>;
  uuid: string;
  empiMediId: string;
  technicaljobCode: string;
  idClass: string;
  idno: string;
  name: string;
  sexCode: string;
  birthDate: string;
  birthPlace: string;
  createrUuid: string;
  updaterUuid: string;
  createDate: string;
  updateDate: string;
  peopleEthnicCode: string;
  firstWorkingDate: string;
  cellPhone: string;
  certiClass: string;
  proClassCode: string;
  medCertiCode: string;
  medCertiClass: string;
  adminPostCode: string;
  hosCertiCode: string;
  nurseCertiCode: string;
  proQualCode: string;
  proPostCode: string;
  eduCode: string;
  acaCode: string;
  stuPostCode: string;
  whoMedpostTag: string;
  deleteTag: string;
  version: string;
  sysDoctorJobList: DoctorJobFields[];
  docStatus: string;
  jobCount: string;
}

// 列表
interface GetList_Params extends _Pager_Params, DoctorFields {}
type ListResult = ResultList<DoctorFields[]>;

export async function getListApi(params: Partial<GetList_Params>) {
  return request<Partial<ListResult>>({
    url: '/doctor/list',
    method: 'get',
    params,
  });
}

// 新增
type _Add_Params = Partial<DoctorFields>;
export async function addApi(data: _Add_Params) {
  return request<Result>({
    url: '/doctor',
    method: 'post',
    data,
  });
}
// 编辑
type _Update_Params = Partial<DoctorFields>;
export async function updateApi(data: _Update_Params) {
  return request<Result>({
    url: '/doctor/edit',
    method: 'post',
    data,
  });
}
export async function importDoctorApi(data: FormData): Promise<Result> {
  return request({
    url: '/doctor/import',
    method: 'post',
    data,
  });
}

export async function getDetailsApi(id: string) {
  return request<Result<DoctorFields>>({
    url: '/doctor/' + id,
    method: 'get',
  });
}

export async function delApi(params: string) {
  return request({
    url: `/doctor/delete/${params}`,
    method: 'get',
  });
}

/**@name 批量操作 */
interface BatchProps {
  docCodes: string;
  docStatus: string;
}
export async function batchApi(params: BatchProps) {
  return request<Result>({
    url: '/doctor/batch',
    method: 'post',
    params,
  });
}

export async function exportDoctorApi() {
  return downloadExcelRequest(
    {
      url: '/doctor/export',
      params: { tempOnly: 1 },
      method: 'post',
    },
    '医护模板',
  );
}
