import kcRequest from "@/service/request/index.js";

// 上传附件
export const uploadAttachments = (orderNo, files) => {
  const fd = new FormData();
  fd.append("orderNo", orderNo);
  (files || []).forEach((f) => fd.append("files", f));
  return kcRequest.uploadFile(`/upload`, fd);
};

// 下载/预览上传的文件（医院验收报告等），GET，返回 Blob
export const getUploadFile = (fileName) => {
  return kcRequest.downloadFile(`/upload/${fileName}`);
};

// 获取附件预览/下载地址
export const getAttachmentUrl = (fileName) => {
  const base = import.meta.env.DEV ? "/api" : window.location.origin;
  return `${base}/upload/${fileName}`;
};
