import request from "@/utils/request";

const upload = (file,url ) => {
  const formData = new FormData();

  formData.append("file", file);
  return request(`/upload/${url}`, { method: "POST", data: formData });
};

/**
 * 上传文件
 * @returns
 */
export function uploadFile(params) {
  const { file, onSuccess, onError } = params;
  upload(file,"taRotation")
    .then((res) => {
      onSuccess(res);
    })
    .catch((e) => {
      onError(e);
    });
  return {
    abort: () => {},
  };
}

/**
 * 上传文件
 * @returns
 */
export function uploadFileTaMandatoryLeave(params) {
  const { file, onSuccess, onError } = params;
  upload(file, "taMandatoryLeave")
    .then((res) => {
      onSuccess(res);
    })
    .catch((e) => {
      onError(e);
    });
  return {
    abort: () => {},
  };
}
