riku
2024-08-23 1788c96aea9247cc36ef8b82734997f1a6a92fb4
src/api/missionApi.js
@@ -1,4 +1,5 @@
import { $http } from './index';
import { Base64 } from 'js-base64';
/**
 *
@@ -17,5 +18,22 @@
  deleteMission(missionCode) {
    let params = `missionCode=${missionCode}`;
    return $http.post(`air/mission/delete?${params}`).then((res) => res.data);
  },
  downloadReport(missionCode) {
    let params = `missionCode=${missionCode}`;
    return $http
      .get(`air/mission/report?${params}`, { responseType: 'blob' })
      .then((res) => {
        const name = Base64.decode(res.headers.get('fileName'));
        const url = window.URL.createObjectURL(res.data);
        const link = document.createElement('a');
        link.href = url;
        link.setAttribute('download', name);
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        window.URL.revokeObjectURL(url);
      });
  }
};