import HTTP              from '@/request/alova';
import { useVisitor }    from '@/stores';


export function uploadFileMethod(file: File, name?: string) {
  const formData = new FormData();
  if (name) formData.append('file', file, name);
  else formData.append('file', file);
  return HTTP.Post<{ name: string; url: string }>(`/file/upload`, formData, {});
}

export function saveFileMethod(params: Record<string, string>) {
  const Visitor = useVisitor();
  params.patientId = Visitor.patientId!;
  return HTTP.Get(`/fdhb-tablet/patientInfoManage/saveTonguefaceImg`, {
    params,
    async transform(data: string, headers) {
      Visitor.resultId = data;
      return data;
    },
  });
}
