对接导入导出,优化页面UI

This commit is contained in:
fks-xuxinyue
2024-08-14 15:21:20 +08:00
parent 4205413418
commit 83119f53e9
13 changed files with 468 additions and 166 deletions

View File

@@ -125,12 +125,14 @@
:body-style="{ paddingBottom: '80px' }"
:footer-style="{ textAlign: 'right' }"
destroyOnClose
title="单位管理"
@close="closeUnitManag">
<div class="addButton">
<div class="ns-form-title titleUnit">
<div class="title">单位管理</div>
<a-button type="primary" @click="addGroup">新增分组</a-button>
<a-button type="primary" @click="addUnit">新增单位</a-button>
</div>
<!-- <div class="addButton">
</div> -->
<div class="treePart">
<div
style="
@@ -245,8 +247,8 @@
const dynamicDisabled = computed(() => {
return formRef.value?.validateResult && userAuthList.value?.length;
});
const fetch = (api, params = { orgId }) => {
return http.post(api, params);
const fetch = (api, params = { orgId }, config) => {
return http.post(api, params, config);
};
const selectTreeDataValue = ref<string>('');
const mainRef = ref();
@@ -640,7 +642,7 @@
type: 'primary',
name: 'carbonEmissionFactorLibraryImport',
extra: {
api: carbonEmissionFactorLibrary.excel, // 导入接口名
api: carbonEmissionFactorLibrary.import, // 导入接口名
params: {
orgId,
},
@@ -659,7 +661,31 @@
label: '导出',
type: 'primary',
handle: () => {
doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx');
const exportQuery = {
orgId: orgId.value,
pageNum: 1,
pageSize: 999,
};
const config = {
responseType: 'blob',
};
fetch(carbonEmissionFactorLibrary.export, exportQuery, 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', 'carbonFactor.xlsx'); // 设置下载的文件名
document.body.appendChild(link);
link.click();
// 清理 URL 对象
window.URL.revokeObjectURL(url);
})
.catch((error) => {
console.error('下载失败:', error);
});
},
},
{
@@ -1101,6 +1127,20 @@
padding-bottom: 10px;
border-bottom: 1px solid #e9e9e9;
}
.titleUnit {
font-weight: bold;
user-select: text;
padding: unset;
margin-bottom: unset;
padding-bottom: unset;
border-bottom: unset;
width: 70%;
height: 5vh;
display: flex;
align-items: center;
justify-content: space-between;
margin-left: 10%;
}
.title {
text-align: left;
height: 32px;
@@ -1140,6 +1180,7 @@
border: 1px solid #bfbfbf;
margin-left: 10%;
flex-direction: column;
border-radius: 12px;
}
.actionMore {
display: none;