|
@@ -498,33 +498,23 @@ export default {
|
|
|
const dateStr = dayjs().format('YYYY-MM');
|
|
|
const fileName = `监督任务数据${dateStr}.xlsx`;
|
|
|
|
|
|
- // 这里根据开发/生产环境切换 baseURL
|
|
|
- const baseURL = process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_URL;
|
|
|
-
|
|
|
- const res = await fetch(baseURL + this.exportUrl, {
|
|
|
- method: 'GET'
|
|
|
- });
|
|
|
-
|
|
|
- if (!res.ok) throw new Error('下载失败');
|
|
|
-
|
|
|
- const blob = await res.blob();
|
|
|
+ // 直接创建 a 标签下载
|
|
|
const link = document.createElement('a');
|
|
|
link.style.display = 'none';
|
|
|
- link.href = URL.createObjectURL(blob);
|
|
|
+ link.href = this.exportUrl;
|
|
|
link.setAttribute('download', fileName);
|
|
|
|
|
|
document.body.appendChild(link);
|
|
|
link.click();
|
|
|
document.body.removeChild(link);
|
|
|
|
|
|
- // 释放内存
|
|
|
- URL.revokeObjectURL(link.href);
|
|
|
this.exportLoading = false;
|
|
|
} catch (err) {
|
|
|
console.error('下载出错:', err);
|
|
|
this.exportLoading = false;
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
handleExportDialogClose() {
|
|
|
this.exportForm.startDate = '';
|
|
|
this.exportDialogVisible = false;
|