优化碳排管理
This commit is contained in:
@@ -78,6 +78,7 @@
|
||||
import { http } from '/nerv-lib/util/http';
|
||||
import { carbonInventoryCheck } from '/@/api/carbonEmissionFactorLibrary';
|
||||
import fillIn from './fillInPage/index.vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
defineOptions({ name: 'CarbonInventoryCheck' });
|
||||
const orgId = ref('');
|
||||
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
|
||||
@@ -241,17 +242,21 @@
|
||||
};
|
||||
fetch(carbonInventoryCheck.downloadZip, deleteId.value, config)
|
||||
.then((res) => {
|
||||
// 创建一个 URL 对象,指向图片数据的 blob
|
||||
const url = window.URL.createObjectURL(new Blob([res]));
|
||||
// 创建一个 <a> 标签,用于触发下载
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', '碳盘查凭证.zip'); // 设置下载的文件名
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
if (res.type === 'application/json') {
|
||||
handlerResponseError(res);
|
||||
} else {
|
||||
// 创建一个 URL 对象,指向图片数据的 blob
|
||||
const url = window.URL.createObjectURL(new Blob([res]));
|
||||
// 创建一个 <a> 标签,用于触发下载
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', '碳盘查凭证.zip'); // 设置下载的文件名
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
// 清理 URL 对象
|
||||
window.URL.revokeObjectURL(url);
|
||||
// 清理 URL 对象
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('下载图片失败:', error);
|
||||
@@ -295,6 +300,21 @@
|
||||
},
|
||||
rowKey: 'id',
|
||||
});
|
||||
const handlerResponseError = (data) => {
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = function () {
|
||||
try {
|
||||
const jsonData = JSON.parse(fileReader.result); // 说明是普通对象数据,后台转换失败
|
||||
console.log('后台返回的信息', jsonData.data);
|
||||
message.warning(jsonData.data);
|
||||
// dosomething……
|
||||
} catch (err) {
|
||||
// 解析成对象失败,说明是正常的文件流
|
||||
console.log('success...');
|
||||
}
|
||||
};
|
||||
fileReader.readAsText(data);
|
||||
};
|
||||
// 填报页点击返回
|
||||
const updateData = (newDataOne, newDataTwo) => {
|
||||
isMainPage.value = newDataOne;
|
||||
|
Reference in New Issue
Block a user